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

This commit is contained in:
Daniel Supernault 2021-06-28 20:19:57 -06:00
parent 3741c76da3
commit d48ebb829c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

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