From: Alexis Laferrière Date: Tue, 10 Nov 2015 13:18:20 +0000 (-0500) Subject: contrib/tnitter: replace `latest_posts` by a 2 args `list_posts` X-Git-Tag: v0.8~88^2~11 X-Git-Url: http://nitlanguage.org contrib/tnitter: replace `latest_posts` by a 2 args `list_posts` Signed-off-by: Alexis Laferrière --- diff --git a/contrib/tnitter/src/action.nit b/contrib/tnitter/src/action.nit index 9eaae5b..21418fa 100644 --- a/contrib/tnitter/src/action.nit +++ b/contrib/tnitter/src/action.nit @@ -208,7 +208,7 @@ class Tnitter else error_html = "" # Load the last 16 Tnits - var posts = db.latest_posts(16) + var posts = db.list_posts(0, 16) db.close var html_posts = new Array[String] diff --git a/contrib/tnitter/src/database.nit b/contrib/tnitter/src/database.nit index 4c88b51..b38fa9b 100644 --- a/contrib/tnitter/src/database.nit +++ b/contrib/tnitter/src/database.nit @@ -79,10 +79,10 @@ class DB end end - # Get the latest tnits - fun latest_posts(count: Int): Array[Post] + # List `count` of the latest Tnits skipping `offset` + fun list_posts(offset, count: Int): Array[Post] do - var stmt = select("user, text FROM posts ORDER BY datetime(posted) DESC LIMIT {count}") + var stmt = select("user, text FROM posts ORDER BY datetime(posted) DESC LIMIT {count} OFFSET {offset}") assert stmt != null else print error or else "?" var posts = new Array[Post]