mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-12 05:24:56 +00:00
Fix tag trend migration failing due to duplicate rows (#33189)
This commit is contained in:
parent
17c02c9210
commit
d29eddc401
|
@ -6,12 +6,8 @@ class MoveTagTrendsToTable < ActiveRecord::Migration[7.2]
|
||||||
disable_ddl_transaction!
|
disable_ddl_transaction!
|
||||||
|
|
||||||
def up
|
def up
|
||||||
redis.zrange('trending_tags:all', 0, -1, with_scores: true).each do |(tag_id, score)|
|
redis.zrange('trending_tags:all', 0, -1, with_scores: true).each_slice(1_000) do |data|
|
||||||
TagTrend.create(
|
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))
|
||||||
tag_id: tag_id,
|
|
||||||
score: score,
|
|
||||||
allowed: redis.zscore('trending_tags:allowed', tag_id).present?
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
TagTrend.recalculate_ordered_rank
|
TagTrend.recalculate_ordered_rank
|
||||||
|
|
Loading…
Reference in a new issue