mirror of
				https://github.com/discourse/discourse.git
				synced 2025-02-25 18:55:32 -06:00 
			
		
		
		
	PERF: Improve cook_url performance for topic thumbnails (#11609)
- Only initialize the S3Helper when needed - Skip initializing the S3Helper for S3Store#cdn_url - Allow cook_url to be passed a `local` hint to skip unnecessary checks
This commit is contained in:
		@@ -88,7 +88,7 @@ class Topic < ActiveRecord::Base
 | 
			
		||||
      Jobs.enqueue(:generate_topic_thumbnails, { topic_id: id, extra_sizes: extra_sizes })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    infos.each { |i| i[:url] = UrlHelper.cook_url(i[:url], secure: original.secure?) }
 | 
			
		||||
    infos.each { |i| i[:url] = UrlHelper.cook_url(i[:url], secure: original.secure?, local: true) }
 | 
			
		||||
 | 
			
		||||
    infos.sort_by! { |i| -i[:width] * i[:height] }
 | 
			
		||||
  end
 | 
			
		||||
@@ -123,7 +123,7 @@ class Topic < ActiveRecord::Base
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    raw_url = thumbnail&.optimized_image&.url || image_upload&.url
 | 
			
		||||
    UrlHelper.cook_url(raw_url, secure: image_upload&.secure?)
 | 
			
		||||
    UrlHelper.cook_url(raw_url, secure: image_upload&.secure?, local: true) if raw_url
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def featured_users
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user