Add support to Mastodon Tag Trends for paging, local tags, and faster refresh

= with phpcbf format auto-correction
This commit is contained in:
Hank Grabowski 2023-02-16 22:55:23 -05:00
parent 90717b602e
commit c5effdadec
2 changed files with 51 additions and 28 deletions

View file

@ -37,11 +37,18 @@ class Tags extends BaseApi
protected function rawContent(array $request = [])
{
$request = $this->getRequest([
'limit' => 20, // Maximum number of results to return. Defaults to 10.
'limit' => 20, // Maximum number of results to return. Defaults to 20.
'offset' => 0,
'friendica_local' => false,
], $request);
$trending = [];
$tags = Tag::getGlobalTrendingHashtags(24, 20);
if ($request['friendica_local']) {
$tags = Tag::getLocalTrendingHashtags(24, $request['limit'], $request['offset']);
} else {
$tags = Tag::getGlobalTrendingHashtags(24, $request['limit'], $request['offset']);
}
foreach ($tags as $tag) {
$tag['name'] = $tag['term'];
$history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]];