Commit bb753fab3c44e29abfe3dcb7e11bb6eff5a8be42

Authored by Victor Costa
1 parent bee029e0

Fix dashboard ranking

lib/gamification_plugin/dashboard_helper.rb
... ... @@ -19,10 +19,10 @@ module GamificationPlugin::DashboardHelper
19 19 # FIXME move these queries to profile model
20 20 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 => 'Person').order('sum(num_points) DESC').group('profiles.id')
21 21 ranking = ranking.where("merit_score_points.created_at >= ?", from_date) if from_date.present?
22   - current_person_ranking = Profile.from("(#{ranking.to_sql}) profiles").where('profiles.id' => current_person.id).first
  22 + profile_ranking = Profile.from("(#{ranking.to_sql}) profiles").where('profiles.id' => profile.id).first
23 23 ranking = ranking.limit(limit)
24 24  
25   - render :partial => 'gamification/ranking', :locals => {:ranking => ranking, :current_person_ranking => current_person_ranking}
  25 + render :partial => 'gamification/ranking', :locals => {:ranking => ranking, :profile_ranking => profile_ranking}
26 26 end
27 27  
28 28 end
... ...
views/gamification/_ranking.html.erb
1 1 <ul class="ranking">
2   - <% if current_person_ranking.present? %>
  2 + <% if profile_ranking.present? %>
3 3 <span><%= _('Your position: ') %></span>
4   - <span><%= current_person_ranking.gamification_position %></span>
  4 + <span><%= profile_ranking.gamification_position %></span>
5 5 <% else %>
6 6 <%= _('Not scored yet') %>
7 7 <% end %>
... ...