Add offset parameter to Mastodon trending Links and Statuses endpoints
This commit is contained in:
parent
6a94632131
commit
e6c93d31c1
|
@ -41,6 +41,7 @@ class Links extends BaseApi
|
||||||
{
|
{
|
||||||
$request = $this->getRequest([
|
$request = $this->getRequest([
|
||||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||||
|
'offset' => 0, // Offset page, Defaults to 0.
|
||||||
], $request);
|
], $request);
|
||||||
|
|
||||||
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
|
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
|
||||||
|
@ -48,7 +49,7 @@ class Links extends BaseApi
|
||||||
$condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]);
|
$condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]);
|
||||||
|
|
||||||
$trending = [];
|
$trending = [];
|
||||||
$statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]);
|
$statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => [$request['offset'], $request['limit']], 'offset' => $request['offset'], 'order' => ['total-actors' => true]]);
|
||||||
while ($status = Post::fetch($statuses)) {
|
while ($status = Post::fetch($statuses)) {
|
||||||
$history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]];
|
$history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]];
|
||||||
$trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray();
|
$trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray();
|
||||||
|
|
|
@ -44,6 +44,7 @@ class Statuses extends BaseApi
|
||||||
|
|
||||||
$request = $this->getRequest([
|
$request = $this->getRequest([
|
||||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||||
|
'offset' => 0, // Offset page, Defaults to 0.
|
||||||
], $request);
|
], $request);
|
||||||
|
|
||||||
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
|
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
|
||||||
|
@ -52,7 +53,7 @@ class Statuses extends BaseApi
|
||||||
$display_quotes = self::appSupportsQuotes();
|
$display_quotes = self::appSupportsQuotes();
|
||||||
|
|
||||||
$trending = [];
|
$trending = [];
|
||||||
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]);
|
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => [$request['offset'], $request['limit']], 'order' => ['total-actors' => true]]);
|
||||||
while ($status = Post::fetch($statuses)) {
|
while ($status = Post::fetch($statuses)) {
|
||||||
try {
|
try {
|
||||||
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
|
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user