From 4fa894925e2d58c4b5f77b48e7612c0a9e472445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sat, 8 Nov 2014 22:33:50 -0500 Subject: [PATCH] Fix bug items sync for the Fever api --- fever/index.php | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/fever/index.php b/fever/index.php index 89535a1..cfa56b6 100644 --- a/fever/index.php +++ b/fever/index.php @@ -128,38 +128,27 @@ route('items', function() { if ($response['auth']) { - $offset = 0; - $direction = 'ASC'; + $query = Database::get('db') + ->table('items') + ->limit(50) + ->columns( + 'rowid', + 'feed_id', + 'title', + 'author', + 'content', + 'url', + 'updated', + 'status', + 'bookmark' + ); if (isset($_GET['since_id']) && is_numeric($_GET['since_id'])) { - $offset = $_GET['since_id']; - $direction = 'ASC'; + $items = $query->gt('rowid', $_GET['since_id']) + ->asc('rowid'); } - else if (isset($_GET['max_id']) && is_numeric($_GET['max_id'])) { - - $offset = $_GET['max_id']; - $direction = 'DESC'; - } - - $query = Database::get('db') - ->table('items') - ->columns( - 'rowid', - 'feed_id', - 'title', - 'author', - 'content', - 'url', - 'updated', - 'status', - 'bookmark' - ) - ->orderby('rowid', $direction) - ->offset($offset) - ->limit(50); - - if (! empty($_GET['with_ids'])) { + else if (! empty($_GET['with_ids'])) { $query->in('rowid', explode(',', $_GET['with_ids'])); }