Permalink
Browse files

Tweaked the rank stuff

  • Loading branch information...
David Davis
David Davis committed Apr 4, 2012
1 parent 95e950a commit 6b2a6d5f22ab8d76d8329f532b915ff26ba0cfa4
View
@@ -28,6 +28,7 @@ on what to work on.
* [Michael Stalker](https://github.com/mstalker) (mstalker)
* [Joseph Jaber](https://github.com/josephjaber) (josephjaber)
* [Edward Anderson](https://github.com/nilbus) (nilbus)
+* [Anatoli Makarevich](https://github.com/makaroni4) (makaroni4)
## Acknowledgements
@@ -2,7 +2,7 @@ class UsersController < ApplicationController
before_filter :restrict_to_admin, only: [:edit,:update,:destroy]
def index
- @users = User.asc(:rank).page(params[:page] || 1)
+ @users = User.asc(:rank).desc(:score).page(params[:page] || 1)
end
def show
@@ -13,7 +13,7 @@
<% @users.each_with_index do |user, i| %>
<tr class="user-record <%= 'self' if user == current_user %>" id="<%= user.id %>">
- <td><%= user.rank || 'undefined' %></td>
+ <td><%= user.rank %></td>
<td class="user"><%= gravatar_image(user.email, 24, style: "margin-right: 0.5em") %><%= user.username %></td>
<td><%= user.solution_count || 0 %></td>
<td><%= user.score || 0 %></td>
@@ -1,6 +1,6 @@
-namespace :user_rank do
+namespace :user do
# add rake task and execute is with Cron every 10 minutes for example
- task :build => :environment do
+ task :set_ranks => :environment do
User.desc(:score).asc(:solution_count).each_with_index do |user, position|
user.update_attribute(:rank, position + 1)
end

0 comments on commit 6b2a6d5

Please sign in to comment.