Add like count and support for uppercase tags

This commit is contained in:
cocococosti 2024-04-23 16:01:18 -04:00
parent 7f9649b467
commit 0572d752be
No known key found for this signature in database
GPG Key ID: FDEE4E9ED2BD9B89
1 changed files with 15 additions and 1 deletions

View File

@ -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 (