[deploy] Sync public reactions count with positive reactions count (#8064)
This commit is contained in:
parent
cd18d2f436
commit
b02bf5ed5a
2 changed files with 14 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue