Skip to content

Instantly share code, notes, and snippets.

@shishirmk
Created November 15, 2012 00:54
Show Gist options
  • Save shishirmk/4075939 to your computer and use it in GitHub Desktop.
Save shishirmk/4075939 to your computer and use it in GitHub Desktop.
def add_headers_and_higher_is_better
test_ids = @table.keys - self.metadata_names
tests = Testname.where(:id => test_ids)
testnames_hash = Hash.new
testdetails = Testdescription.where(:dashboard_id => @dashboard_id, :testname_id => test_ids)
testdetails_hash = Hash[testdetails.collect{ |testdetail| [testdetail.testname_id, testdetail] }]
tests.each do |test|
if testdetails_hash[test.id]
self.insert_higher_is_better(testdetails_hash[test.id])
end
testnames_hash[test.id] = test.testname
end
test_ids.each do |test_id|
val = @table[test_id]
@table.delete(test_id)
testname = testnames_hash[test_id]
@table[testname] = val
end
# All to sort the "only testnames" in the hash
testnames = @table.keys - self.metadata_names
temp = Hash.new
self.metadata_names.each do | name |
temp[name] = @table[name]
end
testnames.sort.each do |testname|
temp[testname] = @table[testname]
end
@table = temp
end
Trace
RuntimeError (can't modify frozen String):
app/models/table.rb:250:in `add_headers_and_higher_is_better'
app/controllers/dashboard_controller.rb:56:in `block in prepare_results'
app/controllers/dashboard_controller.rb:56:in `prepare_results'
app/controllers/dashboard_controller.rb:82:in `show'
@shishirmk
Copy link
Author

Line 250 == Line 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment