]> git.mxchange.org Git - friendica.git/commitdiff
Add offset parameter to Mastodon trending Links and Statuses endpoints
authorHank Grabowski <hankgrabowski@gmail.com>
Fri, 17 Feb 2023 16:59:30 +0000 (11:59 -0500)
committerHank Grabowski <hankgrabowski@gmail.com>
Fri, 17 Feb 2023 16:59:30 +0000 (11:59 -0500)
src/Module/Api/Mastodon/Trends/Links.php
src/Module/Api/Mastodon/Trends/Statuses.php

index 5cf2ed4710782c65cd22afed42b71cb59d16330a..e2a160087586b5bc57aadce0ce32b70705a13eb0 100644 (file)
@@ -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();
index cf287e59c3307d6909196be60b5711a797b5dfe3..6ae9c83dd53b9ed24d2ce31f0cab4bce5b0e34fb 100644 (file)
@@ -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);