1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/app/lib/vacuum/feeds_vacuum.rb
Kaspar V ae62e5fa53
Fix/remove calling private method with send in model (#22951)
* fix(status): remove send usage for private unlink_from_conversations

- make unlink_from_conversations public method
- rename unlink_from_conversations to unlink_from_conversations!
- fix send call on private method in statuses_vacuum and batched_remove_status_service

* fix(feeds_vacuum): replace find_in_batches with in_batches

because active record query results should be a little more efficient than
itterating with map and each. Postgres can grasp such lists of ids much quicker
than ruby can.
Will probably make allmost no difference, but cannot hurt either.
2023-01-11 21:57:24 +01:00

34 lines
698 B
Ruby

# frozen_string_literal: true
class Vacuum::FeedsVacuum
def perform
vacuum_inactive_home_feeds!
vacuum_inactive_list_feeds!
end
private
def vacuum_inactive_home_feeds!
inactive_users.select(:id, :account_id).in_batches do |users|
feed_manager.clean_feeds!(:home, users.pluck(:account_id))
end
end
def vacuum_inactive_list_feeds!
inactive_users_lists.select(:id).in_batches do |lists|
feed_manager.clean_feeds!(:list, lists.ids)
end
end
def inactive_users
User.confirmed.inactive
end
def inactive_users_lists
List.where(account_id: inactive_users.select(:account_id))
end
def feed_manager
FeedManager.instance
end
end