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'])); }