mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 14:40:46 +00:00
Update DiscoverController, improve tag feed perf
This commit is contained in:
parent
9d54550741
commit
d8ff40ebf9
2 changed files with 9 additions and 3 deletions
|
@ -96,8 +96,12 @@ class DiscoverController extends Controller
|
||||||
})
|
})
|
||||||
->values();
|
->values();
|
||||||
} else {
|
} else {
|
||||||
|
if($page != 1) {
|
||||||
|
$res['tags'] = [];
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
$key = 'discover:tags:public_feed:' . $hashtag->id . ':page:' . $page;
|
$key = 'discover:tags:public_feed:' . $hashtag->id . ':page:' . $page;
|
||||||
$tags = Cache::remember($key, 900, function() use($hashtag, $page, $end) {
|
$tags = Cache::remember($key, 43200, function() use($hashtag, $page, $end) {
|
||||||
return collect(StatusHashtagService::get($hashtag->id, $page, $end))
|
return collect(StatusHashtagService::get($hashtag->id, $page, $end))
|
||||||
->filter(function($tag) {
|
->filter(function($tag) {
|
||||||
if(!$tag['status']['local']) {
|
if(!$tag['status']['local']) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ class StatusHashtagService {
|
||||||
|
|
||||||
return StatusHashtag::whereHashtagId($id)
|
return StatusHashtag::whereHashtagId($id)
|
||||||
->whereStatusVisibility('public')
|
->whereStatusVisibility('public')
|
||||||
->whereHas('media')
|
|
||||||
->skip($stop)
|
->skip($stop)
|
||||||
->latest()
|
->latest()
|
||||||
->take(9)
|
->take(9)
|
||||||
|
@ -35,7 +34,10 @@ class StatusHashtagService {
|
||||||
return self::getStatus($i, $id);
|
return self::getStatus($i, $id);
|
||||||
})
|
})
|
||||||
->filter(function ($i) use($filtered) {
|
->filter(function ($i) use($filtered) {
|
||||||
return isset($i['status']) && !empty($i['status']) && !in_array($i['status']['account']['id'], $filtered);
|
return isset($i['status']) &&
|
||||||
|
!empty($i['status']) && !in_array($i['status']['account']['id'], $filtered) &&
|
||||||
|
isset($i['status']['media_attachments']) &&
|
||||||
|
!empty($i['status']['media_attachments']);
|
||||||
})
|
})
|
||||||
->values();
|
->values();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue