-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to jbuilder for simplicity and speed
- Loading branch information
Showing
21 changed files
with
140 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
json.(match, :venue, :location, :status, :time, :fifa_id, | ||
:weather, :attendance, :officials, :stage_name) | ||
|
||
json.home_team_country match.home_team&.country | ||
json.away_team_country match.away_team&.country | ||
json.datetime match.datetime&.utc&.iso8601 | ||
|
||
if match.draw | ||
json.winner 'Draw' | ||
json.winner_code 'Draw' | ||
else | ||
json.winner match.winner&.country | ||
json.winner_code match.winner&.fifa_code | ||
end | ||
json.home_team do | ||
if match.home_team | ||
json.country match.home_team.country | ||
json.code match.home_team.fifa_code | ||
json.goals match.home_team_score | ||
json.penalties match.json_home_team_penalties | ||
else | ||
json.country 'To Be Determined' | ||
json.code 'TBD' | ||
json.team_tbd match.home_team_tbd | ||
end | ||
end | ||
json.away_team do | ||
if match.away_team | ||
json.country match.away_team.country | ||
json.code match.away_team.fifa_code | ||
json.goals match.away_team_score | ||
json.penalties match.json_away_team_penalties | ||
else | ||
json.country 'To Be Determined' | ||
json.code 'TBD' | ||
json.team_tbd match.away_team_tbd | ||
end | ||
end | ||
unless @summary | ||
json.home_team_events do | ||
json.cache! [match.home_team, match.home_team.events], expires_in: @cache_time do | ||
events = match.home_team_events.sort_by { |e| e.time.to_i } | ||
json.array! events do |event| | ||
json.id event.id | ||
json.type_of_event event.type_of_event | ||
json.player event.player | ||
json.time event.time | ||
end | ||
end | ||
end | ||
json.away_team_events do | ||
json.cache! [match.away_team, match.away_team.events], expires_in: @cache_time do | ||
events = match.away_team_events.sort_by { |e| e.time.to_i } | ||
json.array! events do |event| | ||
json.id event.id | ||
json.type_of_event event.type_of_event | ||
json.player event.player | ||
json.time event.time | ||
end | ||
end | ||
end | ||
|
||
json.home_team_statistics do | ||
json.cache! match.home_stats, expires_in: @cache_time do | ||
json.partial! '/matches/stats', stats: match.home_stats | ||
end | ||
end | ||
|
||
json.away_team_statistics do | ||
json.cache! match.away_stats, expires_in: @cache_time do | ||
json.partial! '/matches/stats', stats: match.away_stats | ||
end | ||
end | ||
|
||
json.last_event_update_at match.last_event_update_at&.utc&.iso8601 | ||
json.last_score_update_at match.last_score_update_at&.utc&.iso8601 | ||
end |
8 changes: 3 additions & 5 deletions
8
app/views/matches/match_statistics.json.rabl → app/views/matches/_stats.json.jbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
object @match_statistic | ||
cache @match_statistic, expires_in: @cache_time | ||
node(:country) { root_object.team.country } | ||
attributes :attempts_on_goal, :on_target, :off_target, :blocked, :woodwork, | ||
json.country stats.team.country | ||
json.(stats, :attempts_on_goal, :on_target, :off_target, :blocked, :woodwork, | ||
:corners, :offsides, :ball_possession, :pass_accuracy, :num_passes, | ||
:passes_completed, :distance_covered, :balls_recovered, :tackles, | ||
:clearances, :yellow_cards, :red_cards, :fouls_committed, :tactics, | ||
:starting_eleven, :substitutes | ||
:starting_eleven, :substitutes) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
json.cache_collection! @matches, expires_in: @cache_time do | ||
json.array! @matches, partial: '/matches/match', as: :match | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.