mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-20 20:13:17 +00:00
Merge pull request #4378 from pixelfed/staging
Update CommentPipeline, replace expensive query and mark for refactor
This commit is contained in:
commit
e3bf01c5a2
2 changed files with 12 additions and 8 deletions
|
@ -60,10 +60,12 @@ class CommentPipeline implements ShouldQueue
|
||||||
$actor = $comment->profile;
|
$actor = $comment->profile;
|
||||||
|
|
||||||
if(config('database.default') === 'mysql') {
|
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)");
|
// todo: refactor
|
||||||
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
// $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)");
|
||||||
$count = DB::select($expQuery, [ 'kid' => $status->id ]);
|
// $expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
||||||
$status->reply_count = count($count);
|
// $count = DB::select($expQuery, [ 'kid' => $status->id ]);
|
||||||
|
// $status->reply_count = count($count);
|
||||||
|
$status->reply_count = $status->reply_count + 1;
|
||||||
$status->save();
|
$status->save();
|
||||||
} else {
|
} else {
|
||||||
$status->reply_count = $status->reply_count + 1;
|
$status->reply_count = $status->reply_count + 1;
|
||||||
|
|
|
@ -70,10 +70,12 @@ class StatusReplyPipeline implements ShouldQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config('database.default') === 'mysql') {
|
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)");
|
// todo: refactor
|
||||||
$expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
// $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)");
|
||||||
$count = DB::select($expQuery, [ 'kid' => $reply->id ]);
|
// $expQuery = $exp->getValue(DB::connection()->getQueryGrammar());
|
||||||
$reply->reply_count = count($count);
|
// $count = DB::select($expQuery, [ 'kid' => $reply->id ]);
|
||||||
|
// $reply->reply_count = count($count);
|
||||||
|
$reply->reply_count = $reply->reply_count + 1;
|
||||||
$reply->save();
|
$reply->save();
|
||||||
} else {
|
} else {
|
||||||
$reply->reply_count = $reply->reply_count + 1;
|
$reply->reply_count = $reply->reply_count + 1;
|
||||||
|
|
Loading…
Reference in a new issue