prevent a single image queuing 10+ jobs

This commit is contained in:
Donovan Daniels 2024-10-28 20:34:43 -05:00
parent 023af6527f
commit 41177bc37a
Signed by: Donovan_DMC
GPG Key ID: 907D29CBFD6157BA
2 changed files with 2 additions and 1 deletions

View File

@ -4,7 +4,6 @@ class UpdateExternalCacheJob < ApplicationJob
queue_as :cache queue_as :cache
def perform(image) def perform(image)
return unless image.cache_expired? || image.cached_data.blank?
image.update_cache! image.update_cache!
end end
end end

View File

@ -145,7 +145,9 @@ class ExternalAPIImage < ApplicationRecord
end end
def update_cache def update_cache
return if @cache_updated
UpdateExternalCacheJob.perform_later(self) UpdateExternalCacheJob.perform_later(self)
@cache_updated = true
end end
def update_cache! def update_cache!