Skip to content

Instantly share code, notes, and snippets.

@jeremyvdw
Created April 9, 2012 17:18
Show Gist options
  • Save jeremyvdw/2344813 to your computer and use it in GitHub Desktop.
Save jeremyvdw/2344813 to your computer and use it in GitHub Desktop.
diff --git a/app/models/trophy.rb b/app/models/trophy.rb
index 059ccca..b9bf3ee 100644
--- a/app/models/trophy.rb
+++ b/app/models/trophy.rb
@@ -201,12 +201,12 @@ class Trophy
trophies = trophies_list
- user_values = Statistics::UserActivity::Query.new.for_user(user_id) do
- trophies.map { |trophy| metric_promise(trophy.dimension, trophy.metric) }
+ user_values = Statistics::UserActivity::Query.new.for_user(user_id) do |q|
+ trophies.map { |trophy| q.metric_promise(trophy.dimension, trophy.metric) }
end
trophies.each_with_index do |trophy, index|
- if user_values[index] >= threshold
+ if user_values[index] >= trophy.threshold
reward_user_with_trophy(user_id, trophy.name, trophy.level)
end
end
diff --git a/lib/statistics/user_activity/query.rb b/lib/statistics/user_activity/query.rb
index 95bf40a..4106f94 100644
--- a/lib/statistics/user_activity/query.rb
+++ b/lib/statistics/user_activity/query.rb
@@ -254,7 +254,7 @@ class Statistics::UserActivity::Query < Statistics::UserActivity::Base
}
block.inject(mod)
- result = block.call
+ result = block.call(self)
block.deject
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment