Fix bug items sync for the Fever api

This commit is contained in:
Frédéric Guillot 2014-11-08 22:33:50 -05:00
parent 906f99cf1c
commit 4fa894925e
1 changed files with 17 additions and 28 deletions

View File

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