Explorar o código

Update StatusController, improve share api perf (11s to 72ms)

Daniel Supernault %!s(int64=4) %!d(string=hai) anos
pai
achega
d48ebb829c
Modificáronse 1 ficheiros con 4 adicións e 5 borrados
  1. 4 5
      app/Http/Controllers/StatusController.php

+ 4 - 5
app/Http/Controllers/StatusController.php

@@ -237,16 +237,15 @@ class StatusController extends Controller
 
 
 		$user = Auth::user();
 		$user = Auth::user();
 		$profile = $user->profile;
 		$profile = $user->profile;
-		$status = Status::withCount('shares')
-			->whereIn('scope', ['public', 'unlisted'])
+		$status = Status::whereIn('scope', ['public', 'unlisted'])
 			->findOrFail($request->input('item'));
 			->findOrFail($request->input('item'));
 
 
-		$count = $status->shares()->count();
+		$count = $status->reblogs_count;
 
 
 		$exists = Status::whereProfileId(Auth::user()->profile->id)
 		$exists = Status::whereProfileId(Auth::user()->profile->id)
 				  ->whereReblogOfId($status->id)
 				  ->whereReblogOfId($status->id)
-				  ->count();
-		if ($exists !== 0) {
+				  ->exists();
+		if ($exists == true) {
 			$shares = Status::whereProfileId(Auth::user()->profile->id)
 			$shares = Status::whereProfileId(Auth::user()->profile->id)
 				  ->whereReblogOfId($status->id)
 				  ->whereReblogOfId($status->id)
 				  ->get();
 				  ->get();