DEV: Apply syntax_tree formatting to app/*

This commit is contained in:
David Taylor
2023-01-09 12:20:10 +00:00
parent a641ce4b62
commit 5a003715d3
696 changed files with 18447 additions and 15481 deletions

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
class StylesheetCache < ActiveRecord::Base
self.table_name = 'stylesheet_cache'
self.table_name = "stylesheet_cache"
MAX_TO_KEEP = 50
CLEANUP_AFTER_DAYS = 150
@ -12,21 +12,14 @@ class StylesheetCache < ActiveRecord::Base
return false if where(target: target, digest: digest).exists?
if Rails.env.development?
ActiveRecord::Base.logger = nil
end
ActiveRecord::Base.logger = nil if Rails.env.development?
success = create(target: target, digest: digest, content: content, source_map: source_map)
count = StylesheetCache.count
if count > max_to_keep
remove_lower = StylesheetCache
.where(target: target)
.limit(max_to_keep)
.order('id desc')
.pluck(:id)
.last
remove_lower =
StylesheetCache.where(target: target).limit(max_to_keep).order("id desc").pluck(:id).last
DB.exec(<<~SQL, id: remove_lower, target: target)
DELETE FROM stylesheet_cache
@ -38,15 +31,12 @@ class StylesheetCache < ActiveRecord::Base
rescue ActiveRecord::RecordNotUnique, ActiveRecord::ReadOnlyError
false
ensure
if Rails.env.development? && old_logger
ActiveRecord::Base.logger = old_logger
end
ActiveRecord::Base.logger = old_logger if Rails.env.development? && old_logger
end
def self.clean_up
StylesheetCache.where('created_at < ?', CLEANUP_AFTER_DAYS.days.ago).delete_all
StylesheetCache.where("created_at < ?", CLEANUP_AFTER_DAYS.days.ago).delete_all
end
end
# == Schema Information