Merge branch 'master' of git.ukko.mx:psanchezp/quiniela-mundial
Showing
13 changed files
with
85 additions
and
37 deletions
| 1 | source 'https://rubygems.org' | 1 | source 'https://rubygems.org' |
| 2 | 2 | ||
| 3 | +ruby '2.3.0' | ||
| 3 | git_source(:github) do |repo_name| | 4 | git_source(:github) do |repo_name| |
| 4 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") | 5 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") |
| 5 | "https://github.com/#{repo_name}.git" | 6 | "https://github.com/#{repo_name}.git" |
| ... | @@ -62,3 +63,7 @@ end | ... | @@ -62,3 +63,7 @@ end |
| 62 | 63 | ||
| 63 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem | 64 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem |
| 64 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] | 65 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] |
| 66 | + | ||
| 67 | +group :production do | ||
| 68 | + gem 'rails_12factor' | ||
| 69 | +end | ... | ... |
| ... | @@ -148,6 +148,11 @@ GEM | ... | @@ -148,6 +148,11 @@ GEM |
| 148 | nokogiri (>= 1.6) | 148 | nokogiri (>= 1.6) |
| 149 | rails-html-sanitizer (1.0.4) | 149 | rails-html-sanitizer (1.0.4) |
| 150 | loofah (~> 2.2, >= 2.2.2) | 150 | loofah (~> 2.2, >= 2.2.2) |
| 151 | + rails_12factor (0.0.3) | ||
| 152 | + rails_serve_static_assets | ||
| 153 | + rails_stdout_logging | ||
| 154 | + rails_serve_static_assets (0.0.5) | ||
| 155 | + rails_stdout_logging (0.0.5) | ||
| 151 | railties (5.0.7) | 156 | railties (5.0.7) |
| 152 | actionpack (= 5.0.7) | 157 | actionpack (= 5.0.7) |
| 153 | activesupport (= 5.0.7) | 158 | activesupport (= 5.0.7) |
| ... | @@ -246,6 +251,7 @@ DEPENDENCIES | ... | @@ -246,6 +251,7 @@ DEPENDENCIES |
| 246 | pry | 251 | pry |
| 247 | puma (~> 3.0) | 252 | puma (~> 3.0) |
| 248 | rails (~> 5.0.6) | 253 | rails (~> 5.0.6) |
| 254 | + rails_12factor | ||
| 249 | sass-rails (~> 5.0) | 255 | sass-rails (~> 5.0) |
| 250 | simple_form | 256 | simple_form |
| 251 | slim | 257 | slim | ... | ... |
| ... | @@ -73,7 +73,8 @@ table { | ... | @@ -73,7 +73,8 @@ table { |
| 73 | 73 | ||
| 74 | .upcoming { | 74 | .upcoming { |
| 75 | td { | 75 | td { |
| 76 | - width: 33%; | 76 | + width: 25%; |
| 77 | + font-size: 12px; | ||
| 77 | } | 78 | } |
| 78 | } | 79 | } |
| 79 | 80 | ||
| ... | @@ -94,9 +95,9 @@ table { | ... | @@ -94,9 +95,9 @@ table { |
| 94 | text-align: left; | 95 | text-align: left; |
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | - td, th { | 98 | + // td, th { |
| 98 | - width: 50%; | 99 | + // // width: 50%; |
| 99 | - } | 100 | + // } |
| 100 | } | 101 | } |
| 101 | 102 | ||
| 102 | // Bets | 103 | // Bets |
| ... | @@ -182,3 +183,15 @@ input[type="submit"] { | ... | @@ -182,3 +183,15 @@ input[type="submit"] { |
| 182 | max-width: 70vw; | 183 | max-width: 70vw; |
| 183 | } | 184 | } |
| 184 | } | 185 | } |
| 186 | + | ||
| 187 | +.vs-cell { | ||
| 188 | + width: 40px; | ||
| 189 | +} | ||
| 190 | + | ||
| 191 | +.text-left { text-align: left; width: 100%; } | ||
| 192 | + | ||
| 193 | +td.points { | ||
| 194 | + font-weight: 700; | ||
| 195 | + &.zero { color: red } | ||
| 196 | + &.positive { color: green } | ||
| 197 | +} | ... | ... |
| ... | @@ -2,15 +2,20 @@ class ApplicationController < HeimdallEngine::ApplicationController | ... | @@ -2,15 +2,20 @@ 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 | 5 | + load_leaderboard |
| 6 | check_matches | 6 | check_matches |
| 7 | recent_matches | 7 | recent_matches |
| 8 | @results = check_results | 8 | @results = check_results |
| 9 | end | 9 | end |
| 10 | 10 | ||
| 11 | + def leaderboard | ||
| 12 | + @leaders = Bet.joins(:user).group('users.name').sum(:points) | ||
| 13 | + .sort_by { |k,v| v } | ||
| 14 | + end | ||
| 15 | + | ||
| 11 | private | 16 | private |
| 12 | 17 | ||
| 13 | - def leaderboard | 18 | + def load_leaderboard |
| 14 | @leaders = Bet.joins(:user).group('users.name').sum(:points) | 19 | @leaders = Bet.joins(:user).group('users.name').sum(:points) |
| 15 | .sort_by { |k,v| v }.take(5) | 20 | .sort_by { |k,v| v }.take(5) |
| 16 | end | 21 | end |
| ... | @@ -28,7 +33,7 @@ class ApplicationController < HeimdallEngine::ApplicationController | ... | @@ -28,7 +33,7 @@ class ApplicationController < HeimdallEngine::ApplicationController |
| 28 | def check_results | 33 | def check_results |
| 29 | return [] unless current_user | 34 | return [] unless current_user |
| 30 | current_user.bets.joins(:match).order('matches.date desc') | 35 | current_user.bets.joins(:match).order('matches.date desc') |
| 31 | - .where.not(result: nil) | 36 | + .where.not(points: nil) |
| 32 | .limit(5) | 37 | .limit(5) |
| 33 | end | 38 | end |
| 34 | end | 39 | end | ... | ... |
app/controllers/my_profile_controller.rb
0 → 100644
| 1 | h1 Leaderboard | 1 | h1 Leaderboard |
| 2 | table.leaderboard | 2 | table.leaderboard |
| 3 | tbody | 3 | tbody |
| 4 | - - @leaders.each do |group_name, data| | 4 | + - @leaders.each.with_index do |(user_name, points), i| |
| 5 | - tr | ||
| 6 | - td colspan=2 = group_name | ||
| 7 | - - data[:leaderboard].each do |user_name, points| | ||
| 8 | tr | 5 | tr |
| 6 | + td style='width: 50px' = 1 + i | ||
| 9 | td = user_name | 7 | td = user_name |
| 10 | td = points | 8 | td = points |
| 11 | - - if data[:leaderboard].empty? | 9 | + - if @leaders.empty? |
| 12 | tr | 10 | tr |
| 13 | td colspan=2 There are no results yet | 11 | td colspan=2 There are no results yet |
| 12 | +.text-left style='margin-top: 10px;' | ||
| 13 | + = link_to 'See everyone', leaderboard_path | ... | ... |
| ... | @@ -6,7 +6,7 @@ table | ... | @@ -6,7 +6,7 @@ table |
| 6 | td = r.match.local | 6 | td = r.match.local |
| 7 | td VS | 7 | td VS |
| 8 | td = r.match.visit | 8 | td = r.match.visit |
| 9 | - td = r.points | 9 | + td.points class="#{r.points.to_i.zero? ? 'zero' : 'positive'}" = r.points |
| 10 | - if @results.empty? | 10 | - if @results.empty? |
| 11 | tr | 11 | tr |
| 12 | td colspan=4 There are no finished matches yet. | 12 | td colspan=4 There are no finished matches yet. | ... | ... |
| ... | @@ -5,19 +5,6 @@ table.upcoming | ... | @@ -5,19 +5,6 @@ table.upcoming |
| 5 | tr | 5 | tr |
| 6 | td = l(u.date, format: :short) | 6 | td = l(u.date, format: :short) |
| 7 | td = u.local | 7 | td = u.local |
| 8 | - td VS | 8 | + td.vs-cell VS |
| 9 | td = u.visit | 9 | td = u.visit |
| 10 | 10 | ||
| 11 | -h1 Recent matches | ||
| 12 | -table.recent | ||
| 13 | - tbody | ||
| 14 | - - @recent_matches.each do |match| | ||
| 15 | - tr | ||
| 16 | - td = l(match.date, format: :short) | ||
| 17 | - td = match.local | ||
| 18 | - td = match.score_local | ||
| 19 | - td = match.visit | ||
| 20 | - td = match.score_visit | ||
| 21 | - - if @recent_matches.empty? | ||
| 22 | - tr | ||
| 23 | - td colspan=4 There are no finished matches yet. | ... | ... |
app/views/application/leaderboard.html.slim
0 → 100644
| 1 | +.middle.content | ||
| 2 | + h1 Leaderboard | ||
| 3 | + table.leaderboard | ||
| 4 | + tbody | ||
| 5 | + - @leaders.each.with_index do |(user_name, points), i| | ||
| 6 | + tr | ||
| 7 | + td style='width: 50px' = 1 + i | ||
| 8 | + td = user_name | ||
| 9 | + td = points | ||
| 10 | + - if @leaders.empty? | ||
| 11 | + tr | ||
| 12 | + td colspan=2 There are no results yet | ||
| 13 | + .text-left style='margin-top: 10px;' | ||
| 14 | + = link_to 'Back', root_path |
| 1 | table | 1 | table |
| 2 | thead | 2 | thead |
| 3 | - th Day | 3 | + th style='text-align: left' Day |
| 4 | - th Home | 4 | + th style='text-align: left' Home |
| 5 | - th Your bet | 5 | + th style='text-align: left' Your bet |
| 6 | - th Away | 6 | + th style='text-align: left' Away |
| 7 | - th Your bet | 7 | + th style='text-align: left' Your bet |
| 8 | - th Result | 8 | + th style='text-align: left' Result |
| 9 | - th Home Score | 9 | + th style='text-align: left' Home Score |
| 10 | - th Away Score | 10 | + th style='text-align: left' Away Score |
| 11 | - th Points | 11 | + th style='text-align: left' Points |
| 12 | - pool.matches.each do |match| | 12 | - pool.matches.each do |match| |
| 13 | - bet = current_user.bets.find_or_initialize_by(match_id: match.id) | 13 | - bet = current_user.bets.find_or_initialize_by(match_id: match.id) |
| 14 | tr | 14 | tr |
| ... | @@ -20,5 +20,5 @@ table | ... | @@ -20,5 +20,5 @@ table |
| 20 | td = match.result ? match.result.upcase : 'PENDING' | 20 | td = match.result ? match.result.upcase : 'PENDING' |
| 21 | td = match.score_local | 21 | td = match.score_local |
| 22 | td = match.score_visit | 22 | td = match.score_visit |
| 23 | - td = bet.try(:points) | 23 | + td.points class="#{bet.points.to_i.zero? ? 'zero' : 'positive'}" = bet.try(:points) |
| 24 | 24 | ... | ... |
| ... | @@ -2,6 +2,7 @@ Rails.application.routes.draw do | ... | @@ -2,6 +2,7 @@ Rails.application.routes.draw do |
| 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html |
| 3 | HeimdallEngine.load_routes | 3 | HeimdallEngine.load_routes |
| 4 | root 'application#root' | 4 | root 'application#root' |
| 5 | + get 'leaderboard', to: 'application#leaderboard', as: :leaderboard | ||
| 5 | resources :bets, only: [:index] do | 6 | resources :bets, only: [:index] do |
| 6 | collection do | 7 | collection do |
| 7 | patch :update, as: :put | 8 | patch :update, as: :put | ... | ... |
-
Please register or login to post a comment