Class: Jobs::UpdateAnimatedUploads

Inherits:
Scheduled show all
Defined in:
app/jobs/scheduled/update_animated_uploads.rb

Instance Method Summary collapse

Methods inherited from Scheduled

#perform

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/jobs/scheduled/update_animated_uploads.rb', line 9

def execute(args)
  Upload
    .where("extension = 'gif' OR (extension IS NULL AND original_filename LIKE '%.gif')")
    .where(animated: nil)
    .limit(MAX_PROCESSED_GIF_IMAGES)
    .each do |upload|
      uri = Discourse.store.path_for(upload) || upload.url
      upload.animated = FastImage.animated?(uri)
      upload.save(validate: false)
      upload.optimized_images.destroy_all if upload.animated
    end

  nil
end