1
0
Fork 0
forked from fedi/mastodon
mastodon/app/workers/scheduler/media_cleanup_scheduler.rb
Eugen Rochko cb5b5cb5f7
Slightly reduce RAM usage (#7301)
* No need to re-require sidekiq plugins, they are required via Gemfile

* Add derailed_benchmarks tool, no need to require TTY gems in Gemfile

* Replace ruby-oembed with FetchOEmbedService

Reduce startup by 45382 allocated objects

* Remove preloaded JSON-LD in favour of caching HTTP responses

Reduce boot RAM by about 6 MiB

* Fix tests

* Fix test suite by stubbing out JSON-LD contexts
2018-05-02 18:58:48 +02:00

16 lines
283 B
Ruby

# frozen_string_literal: true
class Scheduler::MediaCleanupScheduler
include Sidekiq::Worker
def perform
unattached_media.find_each(&:destroy)
end
private
def unattached_media
MediaAttachment.reorder(nil).unattached.where('created_at < ?', 1.day.ago)
end
end