mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 07:05:23 +01:00
Fix tag trend migration failing due to duplicate rows (#33189)
This commit is contained in:
parent
17c02c9210
commit
d29eddc401
1 changed files with 2 additions and 6 deletions
|
@ -6,12 +6,8 @@ class MoveTagTrendsToTable < ActiveRecord::Migration[7.2]
|
|||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
redis.zrange('trending_tags:all', 0, -1, with_scores: true).each do |(tag_id, score)|
|
||||
TagTrend.create(
|
||||
tag_id: tag_id,
|
||||
score: score,
|
||||
allowed: redis.zscore('trending_tags:allowed', tag_id).present?
|
||||
)
|
||||
redis.zrange('trending_tags:all', 0, -1, with_scores: true).each_slice(1_000) do |data|
|
||||
TagTrend.upsert_all(data.map { |(tag_id, score)| { tag_id: tag_id, score: score, language: '', allowed: redis.zscore('trending_tags:allowed', tag_id).present? } }, unique_by: %w(tag_id language))
|
||||
end
|
||||
|
||||
TagTrend.recalculate_ordered_rank
|
||||
|
|
Loading…
Reference in a new issue