From 0572d752be93a2bfd41ce1eca51afeb2b82a864e Mon Sep 17 00:00:00 2001 From: cocococosti Date: Tue, 23 Apr 2024 16:01:18 -0400 Subject: [PATCH] Add like count and support for uppercase tags --- script/bulk_import/generic_bulk.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/script/bulk_import/generic_bulk.rb b/script/bulk_import/generic_bulk.rb index fc11305ced7..b3d61214b58 100644 --- a/script/bulk_import/generic_bulk.rb +++ b/script/bulk_import/generic_bulk.rb @@ -1242,9 +1242,23 @@ class BulkImport::Generic < BulkImport::Base likes.close - puts "", "Updating like counts of topics..." + puts "", "Updating like counts of posts..." start_time = Time.now + DB.exec(<<~SQL) + WITH + likes AS ( + SELECT post_id, COUNT(*) AS like_count FROM post_actions WHERE post_action_type_id = 2 GROUP BY post_id + ) + UPDATE posts + SET like_count = likes.like_count + FROM likes + WHERE posts.id = likes.post_id + AND posts.like_count <> likes.like_count + SQL + + puts "", "Updating like counts of topics..." + DB.exec(<<~SQL) WITH likes AS (