mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-30 19:03:21 +00:00
Update DiscoverController, fix trending api
This commit is contained in:
parent
81f23ee970
commit
2ab2c9a974
1 changed files with 5 additions and 1 deletions
|
@ -177,16 +177,20 @@ class DiscoverController extends Controller
|
||||||
$request->input('range') == 'alltime' ? '-1' :
|
$request->input('range') == 'alltime' ? '-1' :
|
||||||
($request->input('range') == 'daily' ? 1 : 31) : 1;
|
($request->input('range') == 'daily' ? 1 : 31) : 1;
|
||||||
|
|
||||||
$key = ':api:discover:trending:v1:range:' . $range;
|
$key = ':api:discover:trending:v2:range:' . $range;
|
||||||
$ttl = now()->addHours(2);
|
$ttl = now()->addHours(2);
|
||||||
$res = Cache::remember($key, $ttl, function() use($range) {
|
$res = Cache::remember($key, $ttl, function() use($range) {
|
||||||
if($range == '-1') {
|
if($range == '-1') {
|
||||||
$res = Status::whereVisibility('public')
|
$res = Status::whereVisibility('public')
|
||||||
|
->whereType('photo')
|
||||||
|
->whereIsNsfw(false)
|
||||||
->orderBy('likes_count','desc')
|
->orderBy('likes_count','desc')
|
||||||
->take(12)
|
->take(12)
|
||||||
->get();
|
->get();
|
||||||
} else {
|
} else {
|
||||||
$res = Status::whereVisibility('public')
|
$res = Status::whereVisibility('public')
|
||||||
|
->whereType('photo')
|
||||||
|
->whereIsNsfw(false)
|
||||||
->orderBy('likes_count','desc')
|
->orderBy('likes_count','desc')
|
||||||
->take(12)
|
->take(12)
|
||||||
->where('created_at', '>', now()->subDays($range))
|
->where('created_at', '>', now()->subDays($range))
|
||||||
|
|
Loading…
Reference in a new issue