1
0
Fork 0

Make prettier

This commit is contained in:
Andrew Tomaka 2015-04-28 11:02:17 -04:00
parent 8d85ef6256
commit 462d47de61
3 changed files with 21 additions and 7 deletions

2
app.rb
View File

@ -37,8 +37,6 @@ get '/bossfight' do
@first_negative = user_raids.first_negative
@soldiers_killed = user_raids.soldiers_lost_to_date(@first_negative.created_at)
@contributers = user_raids.contributors(@first_negative.created_at)
require 'pp'
pp @contributers
erb :bossfight
end

View File

@ -18,10 +18,10 @@ class Raid < ActiveRecord::Base
end
def self.soldiers_lost_to_date(date)
where('created_at < ?', date).sum(:soldiers)
where('created_at <= ?', date).sum(:soldiers)
end
def self.contributors(date)
where('created_at < ?', date).group(:attacker).sum(:soldiers)
where('created_at <= ?', date).group(:attacker).sum(:soldiers)
end
end

View File

@ -19,7 +19,23 @@
</ul>
</div>
<div class="col-md-12">
<% require 'pp' %>
<% pp @contributers %>
<div class="col-md-9">
<table class="table table-striped table-hover table-bordered table-condensed">
<thead>
<tr>
<td>Attacker</td>
<td>Attempts</td>
<td>Soldiers Killed</td>
</tr>
</thead>
<tbody>
<% @contributers.each do |contributer| %>
<tr>
<td><%= contributer[0]%></td>
<td></td>
<td><%= readable_number(contributer[1]) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>