Project

General

Profile

« Previous | Next » 

Revision d9a2ebac

Added by Ohad Levy almost 12 years ago

  • ID d9a2ebac6e9ec0082e60265b794f54a29a1f7e65

[SQL optimizations] - many small optimizations

This is one of a few patches aim to improve Foreman performance
  • Bookmarks have only users, not usergroups
  • added caching to the settings table
  • removed notice message lookups (we are not really using those)
  • added caching to top bar (tabs + bookmarks) and expiry.
  • removed non needed JS to load

View differences:

app/models/setting.rb
def self.per_page; 20 end # can't use our own settings
def self.[](name)
if (record = first(:conditions => { :name => name.to_s }))
record.value
name = name.to_s
cache.fetch name do
where(:name => name).first.try(:value)
end
end
def self.[]=(name, value)
record = find_or_create_by_name name.to_s
name = name.to_s
record = find_or_create_by_name name
record.value = value
cache.delete(name)
record.save!
end
......
def value= val
v = (val.nil? or val == default) ? nil : val.to_yaml
self.class.cache.delete(name.to_s)
write_attribute :value, v
end
......
private
def self.cache
Rails.cache
end
def save_as_settings_type
return true unless settings_type.nil?
t = default.class.to_s.downcase

Also available in: Unified diff