Fix: アンテナに登録された投稿がアンテナ削除時Redisから削除されない問題 (#417)

* Fix: アンテナに登録された投稿がRedisから削除されない問題

* Fix test

* Tootctlに変更

* 処理を共通化
This commit is contained in:
KMY(雪あすか) 2024-01-04 15:28:22 +09:00 committed by GitHub
parent 5d8a9f4757
commit 98753287ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 293 additions and 1 deletions

View file

@ -48,10 +48,35 @@ module Mastodon::CLI
say('OK', :green)
end
desc 'remove_legacy', 'Remove old list and antenna feeds from Redis'
def remove_legacy
current_id = 1
List.reorder(:id).select(:id).find_in_batches do |lists|
current_id = remove_legacy_feeds(:list, lists, current_id)
end
current_id = 1
Antenna.reorder(:id).select(:id).find_in_batches do |antennas|
current_id = remove_legacy_feeds(:antenna, antennas, current_id)
end
say('OK', :green)
end
private
def active_user_accounts
Account.joins(:user).merge(User.active)
end
def remove_legacy_feeds(type, items, current_id)
exist_ids = items.pluck(:id)
last_id = exist_ids.max
ids = Range.new(current_id, last_id).to_a - exist_ids
FeedManager.instance.clean_feeds!(type, ids)
last_id + 1
end
end
end