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,7 +6,7 @@ class Environment | ||
6 | has_many :gamification_plugin_organization_badges, :through => :organizations | 6 | has_many :gamification_plugin_organization_badges, :through => :organizations |
7 | 7 | ||
8 | def gamification_plugin_badges | 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 | end | 10 | end |
11 | 11 | ||
12 | end | 12 | end |
lib/gamification_plugin/badge.rb
lib/gamification_plugin/dashboard_helper.rb
@@ -27,7 +27,7 @@ module GamificationPlugin::DashboardHelper | @@ -27,7 +27,7 @@ module GamificationPlugin::DashboardHelper | ||
27 | 27 | ||
28 | def ranking(target, from_date=nil, limit=10) | 28 | def ranking(target, from_date=nil, limit=10) |
29 | # FIXME move these queries to profile model | 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 | ranking = ranking.where("merit_score_points.created_at >= ?", from_date) if from_date.present? | 31 | ranking = ranking.where("merit_score_points.created_at >= ?", from_date) if from_date.present? |
32 | target_ranking = Profile.from("(#{ranking.to_sql}) profiles").where('profiles.id' => target.id).first | 32 | target_ranking = Profile.from("(#{ranking.to_sql}) profiles").where('profiles.id' => target.id).first |
33 | 33 |
views/gamification/_ranking.html.erb
1 | -<% if ranking.empty? %> | 1 | +<% if ranking.blank? %> |
2 | <div class="ranking-empty"><%= _('Not enough points for this ranking yet') %></div> | 2 | <div class="ranking-empty"><%= _('Not enough points for this ranking yet') %></div> |
3 | <% else %> | 3 | <% else %> |
4 | <ul class="ranking <%= defined?(ranking_class) ? ranking_class : '' %>"> | 4 | <ul class="ranking <%= defined?(ranking_class) ? ranking_class : '' %>"> |