PERF: sites in multisite config can share css files if they are not using a color scheme or category backgrounds

This commit is contained in:
Neil Lalonde 2015-05-05 17:58:36 -04:00
parent 406c8bb340
commit 7f9504abb2
1 changed files with 8 additions and 3 deletions

View File

@ -155,9 +155,14 @@ class DiscourseStylesheets
# digest encodes the things that trigger a recompile
def digest
@digest ||= begin
theme = (cs = ColorScheme.enabled) ? "#{cs.id}-#{cs.version}" : 0
category_updated = Category.last_updated_at
Digest::SHA1.hexdigest("#{RailsMultisite::ConnectionManagement.current_db}-#{theme}-#{DiscourseStylesheets.last_file_updated}-#{category_updated}")
theme = (cs = ColorScheme.enabled) ? "#{cs.id}-#{cs.version}" : false
category_updated = Category.where("background_url IS NOT NULL and background_url != ''").last_updated_at
if theme || category_updated > 0
Digest::SHA1.hexdigest "#{RailsMultisite::ConnectionManagement.current_db}-#{theme}-#{DiscourseStylesheets.last_file_updated}-#{category_updated}"
else
Digest::SHA1.hexdigest "defaults-#{DiscourseStylesheets.last_file_updated}"
end
end
end
end