Skip to content

Commit ad3ebbb

Browse files
committed
chore: update match order display
1 parent cd436d4 commit ad3ebbb

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

app/controllers/cup_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def index
77
description: "Visão geral da Kings Lendas Cup — classificação, partidas e estatísticas."
88
)
99
@standings = load_standings
10-
@recent_matches = @schedule.select { |m| m["Winner"].present? }.last(5)
10+
@recent_matches = @schedule.select { |m| m["Winner"].present? }.first(5)
1111
@next_match = find_next_match
1212
end
1313

@@ -20,7 +20,9 @@ def standings
2020
def matches
2121
set_meta_tags(title: "Partidas — Kings Lendas Cup")
2222
@games_by_unique = @games.index_by { |g| g["UniqueGame"] }
23-
@matches_grouped = @schedule.group_by { |m| m["Phase"] || "Grupos" }
23+
played = @schedule.select { |m| m["Winner"].present? }
24+
upcoming = @schedule.select { |m| m["Winner"].blank? }.sort_by { |m| m["DateTime_UTC"].to_s }
25+
@matches_grouped = (played + upcoming).group_by { |m| m["Phase"] || "Grupos" }
2426
end
2527

2628
def draft
@@ -102,7 +104,7 @@ def build_form_map(schedule)
102104
played = schedule.select { |m| m["Winner"].present? }
103105
teams = TEAMS_DATA.keys.first(6)
104106
teams.each_with_object({}) do |team, hash|
105-
team_matches = played.select { |m| m["Team1"] == team || m["Team2"] == team }.last(5)
107+
team_matches = played.select { |m| m["Team1"] == team || m["Team2"] == team }.first(5)
106108
hash[team] = team_matches.map { |m| m["Winner"] == team ? "W" : "L" }
107109
end
108110
end

app/models/lp_match.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class LpMatch < ApplicationRecord
44
scope :upcoming, -> { where(winner: [ nil, "" ]) }
55
scope :group_stage, -> { where("phase IS NULL OR phase = '' OR (phase NOT LIKE '%quarter%' AND phase NOT LIKE '%semi%' AND phase NOT LIKE '%final%')") }
66
scope :playoffs, -> { where("phase LIKE '%quarter%' OR phase LIKE '%semi%' OR phase LIKE '%final%'") }
7-
scope :ordered, -> { order(:datetime_utc) }
7+
scope :ordered, -> { order(datetime_utc: :desc) }
88

99
def as_leaguepedia_hash
1010
{

0 commit comments

Comments
 (0)