Update DiscoverController, add albums and video to discover trending api

pull/2556/head
Daniel Supernault 2021-01-11 00:31:21 -07:00
rodzic 96afc3e781
commit b2fe219eec
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -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)