kopia lustrzana https://github.com/pixelfed/pixelfed
Update DiscoverController, add albums and video to discover trending api
rodzic
96afc3e781
commit
b2fe219eec
|
@ -170,26 +170,26 @@ class DiscoverController extends Controller
|
|||
public function trendingApi(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'range' => 'nullable|string|in:daily,monthly,alltime'
|
||||
'range' => 'nullable|string|in:daily,monthly'
|
||||
]);
|
||||
|
||||
$range = $request->filled('range') ?
|
||||
$request->input('range') == 'alltime' ? '-1' :
|
||||
($request->input('range') == 'daily' ? 1 : 31) : 1;
|
||||
|
||||
$key = ':api:discover:trending:v2:range:' . $range;
|
||||
$key = ':api:discover:trending:v2.1:range:' . $range;
|
||||
$ttl = now()->addHours(2);
|
||||
$res = Cache::remember($key, $ttl, function() use($range) {
|
||||
if($range == '-1') {
|
||||
$res = Status::whereScope('public')
|
||||
->whereType('photo')
|
||||
->whereIn('type', ['photo', 'photo:album', 'video'])
|
||||
->whereIsNsfw(false)
|
||||
->orderBy('likes_count','desc')
|
||||
->take(12)
|
||||
->get();
|
||||
} else {
|
||||
$res = Status::whereScope('public')
|
||||
->whereType('photo')
|
||||
->whereIn('type', ['photo', 'photo:album', 'video'])
|
||||
->whereIsNsfw(false)
|
||||
->orderBy('likes_count','desc')
|
||||
->take(12)
|
||||
|
|
Ładowanie…
Reference in New Issue