Browse Source

Update DiscoverController, add albums and video to discover trending api

Daniel Supernault 4 years ago
parent
commit
b2fe219eec
1 changed files with 4 additions and 4 deletions
  1. 4 4
      app/Http/Controllers/DiscoverController.php

+ 4 - 4
app/Http/Controllers/DiscoverController.php

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