Commit b22222a8bb9432e958b980c3d1b6728888cb48d4
1 parent
3bd7c4a3
Exists in
master
and in
1 other branch
Be prepared for rails4
Showing
4 changed files
with
4 additions
and
4 deletions
Show diff stats
lib/ext/environment.rb
... | ... | @@ -6,7 +6,7 @@ class Environment |
6 | 6 | has_many :gamification_plugin_organization_badges, :through => :organizations |
7 | 7 | |
8 | 8 | def gamification_plugin_badges |
9 | - GamificationPlugin::Badge.from("#{gamification_plugin_organization_badges.union(gamification_plugin_environment_badges).to_sql} as #{GamificationPlugin::Badge.table_name}") | |
9 | + GamificationPlugin::Badge.joins('inner join profiles on profiles.id = owner_id').where(['owner_id = ? or profiles.environment_id = ?', self.id, self.id]) | |
10 | 10 | end |
11 | 11 | |
12 | 12 | end | ... | ... |
lib/gamification_plugin/badge.rb
lib/gamification_plugin/dashboard_helper.rb
... | ... | @@ -27,7 +27,7 @@ module GamificationPlugin::DashboardHelper |
27 | 27 | |
28 | 28 | def ranking(target, from_date=nil, limit=10) |
29 | 29 | # FIXME move these queries to profile model |
30 | - ranking = Profile.select('profiles.*, sum(num_points) as gamification_points, ROW_NUMBER() OVER(order by sum(num_points) DESC) as gamification_position').joins(:sash => {:scores => :score_points}).where(:type => target.class).order('sum(num_points) DESC').group('profiles.id') | |
30 | + ranking = Profile.select('profiles.*, sum(num_points) as gamification_points, ROW_NUMBER() OVER(order by sum(num_points) DESC) as gamification_position').joins(:sash => {:scores => :score_points}).where(:type => target.class).reorder('sum(num_points) DESC').group('profiles.id') | |
31 | 31 | ranking = ranking.where("merit_score_points.created_at >= ?", from_date) if from_date.present? |
32 | 32 | target_ranking = Profile.from("(#{ranking.to_sql}) profiles").where('profiles.id' => target.id).first |
33 | 33 | ... | ... |
views/gamification/_ranking.html.erb