contrib/tnitter: replace `latest_posts` by a 2 args `list_posts`
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 10 Nov 2015 13:18:20 +0000 (08:18 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 11 Nov 2015 19:50:15 +0000 (14:50 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/tnitter/src/action.nit
contrib/tnitter/src/database.nit

index 9eaae5b..21418fa 100644 (file)
@@ -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]
index 4c88b51..b38fa9b 100644 (file)
@@ -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]