Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rdp/freeldssheetmusic.org
base: f884623c5d
...
head fork: rdp/freeldssheetmusic.org
compare: f99cb14863
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
21 app/models/cache.rb
@@ -24,6 +24,27 @@ def self.verify_type type
raise type + ' not in types ' + CACHE_TYPES.inspect unless CACHE_TYPES.contain? type
end
+ def self.map_get_or_set(collection, some_unique_identifier, type, get_int_proc, &block)
+ # lodo not need get_int_proc at all...
+
+ hash_keys = collection.map{|item|
+ [get_int_proc[item], some_unique_identifier, type].hash
+ }
+ all_got = Cache.find(:all, :conditions => ['hash_key in (?)', hash_keys])
+ # hash them and search them, in case the order comes back weird...
+ hashed = {}
+ all_got.each{|cache| hashed[cache.hash_key] = cache.string_value}
+ out = []
+ hash_keys.each_with_index{|hash_key, idx|
+ if hashed[hash_key]
+ out << hashed[hash_key]
+ else
+ out << get_or_set_int(get_int_proc[collection[idx]], some_unique_identifier, type) { block.call(collection[idx]) }
+ end
+ }
+ out
+ end
+
def self.get_or_set_int(int, some_unique_identifier, type)
verify_type type
hash = [int, some_unique_identifier, type].hash
View
2  app/models/product.rb
@@ -169,7 +169,7 @@ def find_problems expensive=true# true until I can figure out what in the world
problems << "no topics associated with song yet."
end
if self.original_tag && self.hymn_tag
- problems << "is tagged with both original and hymn? probably wants to be just hymn tag"
+ problems << "is tagged with both original and hymn? possibly wants to be just hymn tag" unless self.description =~ /original/i
end
for composer_tag in self.composer_tags
View
9 app/views/music/index.rhtml
@@ -58,11 +58,10 @@ unused!
<%= Cache.get_or_set_int(@products.map(&:id).hash, 'music_box_display' + session[:user].to_s, 'group_products') {
out = '' # is there some elegant way? hmm...
- for product in @products
- this_product_box = Cache.get_or_set_int(product.id, 'music_box_display2' + session[:user].to_s, 'single_product') { render :partial => 'product', :locals => {:product => product}, :to => :string }
- out << this_product_box
- end
- out
+ partials = Cache.map_get_or_set(@products, 'music_box_display2' + session[:user].to_s, 'single_product', proc{|p| p.id}) {|product|
+ render :partial => 'product', :locals => {:product => product}, :to => :string
+ }
+ partials.join
}
%>

No commit comments for this range

Something went wrong with that request. Please try again.