From: Hank Grabowski Date: Fri, 17 Feb 2023 16:59:30 +0000 (-0500) Subject: Add offset parameter to Mastodon trending Links and Statuses endpoints X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e6c93d31c17760c76909f0569176a1ec3050dc78;p=friendica.git Add offset parameter to Mastodon trending Links and Statuses endpoints --- diff --git a/src/Module/Api/Mastodon/Trends/Links.php b/src/Module/Api/Mastodon/Trends/Links.php index 5cf2ed4710..e2a1600875 100644 --- a/src/Module/Api/Mastodon/Trends/Links.php +++ b/src/Module/Api/Mastodon/Trends/Links.php @@ -41,6 +41,7 @@ class Links extends BaseApi { $request = $this->getRequest([ 'limit' => 10, // Maximum number of results to return. Defaults to 10. + 'offset' => 0, // Offset page, Defaults to 0. ], $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` > ?", @@ -48,7 +49,7 @@ class Links extends BaseApi $condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]); $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)) { $history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]]; $trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray(); diff --git a/src/Module/Api/Mastodon/Trends/Statuses.php b/src/Module/Api/Mastodon/Trends/Statuses.php index cf287e59c3..6ae9c83dd5 100644 --- a/src/Module/Api/Mastodon/Trends/Statuses.php +++ b/src/Module/Api/Mastodon/Trends/Statuses.php @@ -44,6 +44,7 @@ class Statuses extends BaseApi $request = $this->getRequest([ 'limit' => 10, // Maximum number of results to return. Defaults to 10. + 'offset' => 0, // Offset page, Defaults to 0. ], $request); $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(); $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)) { try { $trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);