Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

top matches table

  • Loading branch information...
commit 2e15998d1b0b179d5e4a16349e789e2dd6f0ff25 1 parent e546dbf
@aserafin aserafin authored
View
4 app/models/tournament.rb
@@ -13,6 +13,10 @@ def recently_played(limit)
self.matches.confirmed.order('created_at desc').limit(limit)
end
+ def top_matches(limit)
+ self.matches.confirmed.includes(:score).order('(coalesce(scores.home, 0) + coalesce(scores.away, 0)) desc').limit(limit)
+ end
+
def ranking
::Ranking.new(rating)
end
View
6 app/views/welcome/_top_matches.html.slim
@@ -0,0 +1,6 @@
+section.topmatches
+ h3 Top matches
+ .table-container
+ table.table
+ tbody
+ = render partial: 'match', collection: Tournament.default.top_matches(10), as: :match
View
12 app/views/welcome/index.html.slim
@@ -44,14 +44,4 @@ section.table.standings
.bottom.clearfix
= render partial: 'recently_played'
-
- section.topmatches
- h3 Top matches
- .table-container
- table.table
- tbody
- tr
- td 1
- td.competitor Pawel Kowalski
- td.score 7 : 5
- td.competitor Oskar Wroblewski
+ = render partial: 'top_matches'
Please sign in to comment.
Something went wrong with that request. Please try again.