Add "next_start" to JSON API result on posts

This commit is contained in:
Bofh 2022-12-24 02:50:17 +01:00
parent 5f2cc85c9a
commit 81b21d838f
1 changed files with 8 additions and 2 deletions

View File

@ -26,8 +26,13 @@ ORDER BY id ASC LIMIT '.$limit.'
unset($object['reblog_of_id']);
}
$delay = $pg->fetch('SELECT COUNT(1) FROM statuses WHERE id > '.$objects[count($objects)-1]['id']);
$delay = intval($delay['count']);
$delay = 0;
$next_start = null;
if (count($objects) > 0) {
$delay = $pg->fetch('SELECT COUNT(1) FROM statuses WHERE id > '.$objects[count($objects)-1]['id']);
$delay = intval($delay['count']);
$next_start = $objects[count($objects)-1]['id'];
}
if ($delay > $limit)
$delay = ['total' => $delay, 'ticks' => intval($delay / $limit)];
else $delay = ['total' => $delay, 'ticks' => 1 ];
@ -37,6 +42,7 @@ ORDER BY id ASC LIMIT '.$limit.'
'items' => $objects,
'limit' => $limit,
'delay' => $delay,
'next_start' => $next_start,
]);
};
$_();