contributers test
This commit is contained in:
parent
3cc029a7af
commit
c78ff9039a
3 changed files with 8 additions and 0 deletions
1
app.rb
1
app.rb
|
@ -36,6 +36,7 @@ get '/bossfight/?:username' do
|
||||||
user_raids = Raid.for_user(@username)
|
user_raids = Raid.for_user(@username)
|
||||||
@first_negative = user_raids.first_negative
|
@first_negative = user_raids.first_negative
|
||||||
@soldiers_lost_to_date = user_raids.soldiers_lost_to_date(@first_negative.created_at)
|
@soldiers_lost_to_date = user_raids.soldiers_lost_to_date(@first_negative.created_at)
|
||||||
|
@contributers = user_raids.contributors(@first_negative.created_at)
|
||||||
|
|
||||||
erb :bossfight
|
erb :bossfight
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,4 +20,8 @@ class Raid < ActiveRecord::Base
|
||||||
def self.soldiers_lost_to_date(date)
|
def self.soldiers_lost_to_date(date)
|
||||||
where('created_at < ?', date).sum(:soldiers)
|
where('created_at < ?', date).sum(:soldiers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.contributers(date)
|
||||||
|
where('created_at < ?', date).group(:attacker).sum(:soldiers)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,3 +7,6 @@
|
||||||
<% if @soldiers_lost_to_date %>
|
<% if @soldiers_lost_to_date %>
|
||||||
Soliders killed before walls broken: <%= readable_number(@soldiers_lost_to_date) %>
|
Soliders killed before walls broken: <%= readable_number(@soldiers_lost_to_date) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% require 'pp' %>
|
||||||
|
<% pp @contributers %>
|
||||||
|
|
Loading…
Reference in a new issue