[deploy] Sync public reactions count with positive reactions count (#8064)

This commit is contained in:
Andy Zhao 2020-05-26 15:41:51 -04:00 committed by GitHub
parent cd18d2f436
commit b02bf5ed5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -1,8 +1,8 @@
module DataUpdateScripts
class UpdatePublicReactionsCountFromPositiveReactionsCount
def run
ActiveRecord::Base.connection.execute("UPDATE articles SET public_reactions_count = positive_reactions_count, previous_public_reactions_count = previous_positive_reactions_count")
ActiveRecord::Base.connection.execute("UPDATE comments SET public_reactions_count = positive_reactions_count")
# ActiveRecord::Base.connection.execute("UPDATE articles SET public_reactions_count = positive_reactions_count, previous_public_reactions_count = previous_positive_reactions_count")
# ActiveRecord::Base.connection.execute("UPDATE comments SET public_reactions_count = positive_reactions_count")
end
end
end

View file

@ -0,0 +1,12 @@
module DataUpdateScripts
class UpdatePublicReactionCountsAgain
def run
article_count = Article.count
comment_count = Comment.count
ActiveRecord::Base.connection.execute("UPDATE articles SET public_reactions_count = positive_reactions_count, previous_public_reactions_count = previous_positive_reactions_count WHERE id <= #{article_count / 2}")
ActiveRecord::Base.connection.execute("UPDATE articles SET public_reactions_count = positive_reactions_count, previous_public_reactions_count = previous_positive_reactions_count WHERE id > #{article_count / 2}")
ActiveRecord::Base.connection.execute("UPDATE comments SET public_reactions_count = positive_reactions_count WHERE id <= #{comment_count / 2}")
ActiveRecord::Base.connection.execute("UPDATE comments SET public_reactions_count = positive_reactions_count WHERE id > #{comment_count / 2}")
end
end
end