From 1ffbc1c7ece21c80d24d9ce02088f30ba4afa507 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 10 Oct 2019 19:06:02 -0600 Subject: [PATCH 1/2] Add Fix Likes command --- app/Console/Commands/FixLikes.php | 75 +++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 app/Console/Commands/FixLikes.php diff --git a/app/Console/Commands/FixLikes.php b/app/Console/Commands/FixLikes.php new file mode 100644 index 000000000..adb4ee454 --- /dev/null +++ b/app/Console/Commands/FixLikes.php @@ -0,0 +1,75 @@ +get()->count(); + + if($limit > 1000) { + if($this->confirm('We have found more than 1000 records to update, this may take a few moments. Are you sure you want to continue?') == false) { + $this->error('Cancelling command...'); + return; + } + } + + $bar = $this->output->createProgressBar($limit); + $this->line(' '); + $this->info(' Starting like count fix ...'); + $this->line(' '); + $bar->start(); + + Like::selectRaw('count(id) as count, status_id') + ->groupBy('status_id') + ->chunk($chunk, function($likes) use($bar) { + foreach($likes as $like) { + $s = Status::find($like['status_id']); + if($s && $s->likes_count == 0) { + $s->likes_count = $like['count']; + $s->save(); + } + $bar->advance(); + } + }); + + $bar->finish(); + $this->line(' '); + $this->line(' '); + } +} From 86cb7d09013df483eaf344f942779ee7529b0357 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 10 Oct 2019 19:13:33 -0600 Subject: [PATCH 2/2] Update PublicApiController --- app/Http/Controllers/PublicApiController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index ac8bfea60..64faa05e1 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -646,6 +646,8 @@ class PublicApiController extends Controller 'in_reply_to_id', 'reblog_of_id', 'is_nsfw', + 'likes_count', + 'reblogs_count', 'scope', 'local', 'created_at',