Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
various little cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
dougalcorn committed Feb 28, 2012
1 parent 65dfe1f commit 477d75d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/historical_game.rb
Expand Up @@ -16,7 +16,7 @@ def as_json(options = {})
:change => change,
}
(GAME_ATTRIBUTES + PLAYER_ATTRIBUTES).each do |attr|
attributes[attr.gsub(/last_/,'')] = self.send(attr) if self.send(attr)
attributes[attr.to_s.gsub(/last_/,'')] = self.send(attr) if self.send(attr)
end
attributes
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/player.rb
Expand Up @@ -40,6 +40,10 @@ def score_history
@score_history ||= ScoreHistory.new(self).history
end

def avg_games_per_day
(p.games.count / (p.games.first.created_at - p.games.last.created_at) / 3600 / 24).round
end

def update_rank!(params = {})
rank = params[:attr] || :rank
self.last_game_id = params[:game].id if params[:game]
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/rescore.rake
Expand Up @@ -8,6 +8,6 @@ task :rescore, [:initial_score] => :environment do |t, args|
player.save
end

Game.order("created_at ASC").each { |g| g.update_ranks }
Game.order("created_at ASC, id ASC").each { |g| g.update_ranks }

end

0 comments on commit 477d75d

Please sign in to comment.