Showing
1 changed file
with
18 additions
and
0 deletions
| ... | @@ -2,5 +2,23 @@ class ApplicationController < HeimdallEngine::ApplicationController | ... | @@ -2,5 +2,23 @@ class ApplicationController < HeimdallEngine::ApplicationController | 
| 2 | protect_from_forgery with: :exception | 2 | protect_from_forgery with: :exception | 
| 3 | 3 | ||
| 4 | def root | 4 | def root | 
| 5 | + @leaderboard = check_leaderboard | ||
| 6 | + @upcoming_matches = check_matches | ||
| 7 | + @results = check_results | ||
| 8 | + end | ||
| 9 | + | ||
| 10 | + private | ||
| 11 | + | ||
| 12 | + def check_leaderboard | ||
| 13 | + User.all.order_by(&:user_score).take(5) | ||
| 14 | + end | ||
| 15 | + | ||
| 16 | + def check_matches | ||
| 17 | + Match.active.order(date: :ASC).limit(5) | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | + def check_results | ||
| 21 | + return [] unless @current_user | ||
| 22 | + @current_user.bets.join(:matches).order(match: { date: :ASC }).limit(5) | ||
| 5 | end | 23 | end | 
| 6 | end | 24 | end | ... | ... | 
- 
Please register or login to post a comment