浏览代码

Update InternalApiController

Daniel Supernault 6 年之前
父节点
当前提交
2254ecf27d
共有 1 个文件被更改,包括 5 次插入10 次删除
  1. 5 10
      app/Http/Controllers/InternalApiController.php

+ 5 - 10
app/Http/Controllers/InternalApiController.php

@@ -136,34 +136,31 @@ class InternalApiController extends Controller
         });
         });
         $following = array_merge($following, $filters);
         $following = array_merge($following, $filters);
 
 
-        $people = Cache::remember('feature:discover:people:'.$pid, 15, function() use ($following) {
-            return Profile::select('id', 'name', 'username')
+        $people = Profile::select('id', 'name', 'username')
             ->with('avatar')
             ->with('avatar')
-            ->inRandomOrder()
+            ->orderByRaw('rand()')
             ->whereHas('statuses')
             ->whereHas('statuses')
             ->whereNull('domain')
             ->whereNull('domain')
             ->whereNotIn('id', $following)
             ->whereNotIn('id', $following)
             ->whereIsPrivate(false)
             ->whereIsPrivate(false)
             ->take(3)
             ->take(3)
             ->get();
             ->get();
-        });
 
 
-        $posts = Cache::remember('feature:discover:posts:'.$pid, 60, function() use ($following) {
-            return Status::select('id', 'caption', 'profile_id')
+        $posts = Status::select('id', 'caption', 'profile_id')
               ->whereNull('in_reply_to_id')
               ->whereNull('in_reply_to_id')
               ->whereNull('reblog_of_id')
               ->whereNull('reblog_of_id')
               ->whereIsNsfw(false)
               ->whereIsNsfw(false)
               ->whereVisibility('public')
               ->whereVisibility('public')
               ->whereNotIn('profile_id', $following)
               ->whereNotIn('profile_id', $following)
-              ->withCount(['comments', 'likes'])
+              ->with('media')
               ->orderBy('created_at', 'desc')
               ->orderBy('created_at', 'desc')
               ->take(21)
               ->take(21)
               ->get();
               ->get();
-          });
 
 
         $res = [
         $res = [
             'people' => $people->map(function($profile) {
             'people' => $people->map(function($profile) {
                 return [
                 return [
+                    'id'    => $profile->id,
                     'avatar' => $profile->avatarUrl(),
                     'avatar' => $profile->avatarUrl(),
                     'name' => $profile->name,
                     'name' => $profile->name,
                     'username' => $profile->username,
                     'username' => $profile->username,
@@ -174,8 +171,6 @@ class InternalApiController extends Controller
                 return [
                 return [
                     'url' => $post->url(),
                     'url' => $post->url(),
                     'thumb' => $post->thumb(),
                     'thumb' => $post->thumb(),
-                    'comments_count' => $post->comments_count,
-                    'likes_count' => $post->likes_count,
                 ];
                 ];
             })
             })
         ];
         ];