Merge pull request #4378 from pixelfed/staging

Update CommentPipeline, replace expensive query and mark for refactor
pull/4394/head
daniel 2023-05-13 17:38:33 -06:00 zatwierdzone przez GitHub
commit e3bf01c5a2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 12 dodań i 8 usunięć

Wyświetl plik

@ -60,10 +60,12 @@ class CommentPipeline implements ShouldQueue
$actor = $comment->profile;
if(config('database.default') === 'mysql') {
$exp = DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)");
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
$count = DB::select($expQuery, [ 'kid' => $status->id ]);
$status->reply_count = count($count);
// todo: refactor
// $exp = DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)");
// $expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
// $count = DB::select($expQuery, [ 'kid' => $status->id ]);
// $status->reply_count = count($count);
$status->reply_count = $status->reply_count + 1;
$status->save();
} else {
$status->reply_count = $status->reply_count + 1;

Wyświetl plik

@ -70,10 +70,12 @@ class StatusReplyPipeline implements ShouldQueue
}
if(config('database.default') === 'mysql') {
$exp = DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)");
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
$count = DB::select($expQuery, [ 'kid' => $reply->id ]);
$reply->reply_count = count($count);
// todo: refactor
// $exp = DB::raw("select id, in_reply_to_id from statuses, (select @pv := :kid) initialisation where id > @pv and find_in_set(in_reply_to_id, @pv) > 0 and @pv := concat(@pv, ',', id)");
// $expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
// $count = DB::select($expQuery, [ 'kid' => $reply->id ]);
// $reply->reply_count = count($count);
$reply->reply_count = $reply->reply_count + 1;
$reply->save();
} else {
$reply->reply_count = $reply->reply_count + 1;