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 @first_negative = user_raids.first_negative
@soldiers_killed = user_raids.soldiers_lost_to_date(@first_negative.created_at) @soldiers_killed = user_raids.soldiers_lost_to_date(@first_negative.created_at)
@contributers = user_raids.contributors(@first_negative.created_at) @contributers = user_raids.contributors(@first_negative.created_at)
require 'pp'
pp @contributers
erb :bossfight erb :bossfight
end end

View file

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

View file

@ -19,7 +19,23 @@
</ul> </ul>
</div> </div>
<div class="col-md-12"> <div class="col-md-9">
<% require 'pp' %> <table class="table table-striped table-hover table-bordered table-condensed">
<% pp @contributers %> <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> </div>