Track last attack
This commit is contained in:
parent
b3d110ea39
commit
ab9322581e
2 changed files with 19 additions and 5 deletions
20
app.rb
20
app.rb
|
@ -13,13 +13,27 @@ get '/' do
|
|||
|
||||
mechanize = Mechanize.new
|
||||
page = mechanize.get('http://trugul.com/highscores')
|
||||
# //div[@id='allEdition']/table//tr/td/span[@class='symbol']/a"
|
||||
highscores = page.search "//table[@id='highscores_table']//tr[@class='clickable']/td[2]"
|
||||
@top20 = []
|
||||
|
||||
require 'pp'
|
||||
@top20 = {}
|
||||
highscores.each do |td_user|
|
||||
@top20 << td_user.text.strip
|
||||
user = td_user.text.scan(/[A-Za-z]+/)
|
||||
@top20[user.first] = nil
|
||||
end
|
||||
|
||||
@top20.keys.each do |top20|
|
||||
@raids.each do |raid|
|
||||
if raid.attacker == top20 || raid.defender == top20
|
||||
@top20[top20] = raid.created_at
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# get last attack for each
|
||||
# order by date
|
||||
|
||||
erb :index
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
<div class="col-md-3">
|
||||
<ul class="list-group">
|
||||
<% @top20.each do |user| %>
|
||||
<li class="list-group-item"><%= user %></li>
|
||||
<% @top20.each do |user, last| %>
|
||||
<li class="list-group-item"><%= user %><span class="pull-right"><%= last.strftime('%H:%M on %m-%d-%Y') if last %></li>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue