catstodon/app/lib/vacuum/feeds_vacuum.rb
Claire 221580a3af Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/home_controller.rb`:
  Upstream made it so `/web` is available to non-logged-in users
  and `/` redirects to `/web` instead of `/about`.
  Kept our version since glitch-soc's WebUI doesn't have what's
  needed yet and I think /about is still a much better landing
  page anyway.
- `app/models/form/admin_settings.rb`:
  Upstream added new settings, and glitch-soc had an extra setting.
  Not really a conflict.
  Added upstream's new settings.
- `app/serializers/initial_state_serializer.rb`:
  Upstream added a new `server` initial state object.
  Not really a conflict.
  Merged upstream's changes.
- `app/views/admin/settings/edit.html.haml`:
  Upstream added new settings.
  Not really a conflict.
  Merged upstream's changes.
- `app/workers/scheduler/feed_cleanup_scheduler.rb`:
  Upstream refactored that part and removed the file.
  Ported our relevant changes into `app/lib/vacuum/feeds_vacuum.rb`
- `config/settings.yml`:
  Upstream added new settings.
  Not a real conflict.
  Added upstream's new settings.
2022-10-02 18:46:22 +02:00

41 lines
920 B
Ruby

# frozen_string_literal: true
class Vacuum::FeedsVacuum
def perform
vacuum_inactive_home_feeds!
vacuum_inactive_list_feeds!
vacuum_inactive_direct_feeds!
end
private
def vacuum_inactive_home_feeds!
inactive_users.select(:id, :account_id).find_in_batches do |users|
feed_manager.clean_feeds!(:home, users.map(&:account_id))
end
end
def vacuum_inactive_list_feeds!
inactive_users_lists.select(:id).find_in_batches do |lists|
feed_manager.clean_feeds!(:list, lists.map(&:id))
end
end
def vacuum_inactive_direct_feeds!
inactive_users_lists.select(:id).find_in_batches do |lists|
feed_manager.clean_feeds!(:direct, lists.map(&:id))
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