Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/jobs/match_update_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def update_matches_future(url)
match.group = Group.find_by(round: match.round, api_code: match_info["group"]) if match_info["group"]
match.api_id = match_info['id']
match.location = match_info['venue']
match.minute = match_info['minute']
match.kickoff_time = kickoff_time
match.save
p match.errors.full_messages if match.errors.any?
Expand Down
4 changes: 4 additions & 0 deletions app/jobs/schedule_daily_tasks_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def perform
matches = competition.matches.where(kickoff_time: Date.today.all_day)
matches.pluck(:kickoff_time).uniq.each do |kickoff_time|
MatchStartedJob.set(wait_until: kickoff_time).perform_later(kickoff_time)
# Calls the API during the matches to get the current time
150.times do |i|
MatchUpdateJob.set(wait_until: kickoff_time + i.minutes).perform_later(competition.id)
end
Comment on lines +11 to +14
end
# Schedules notifications for rounds starting tomorrow
rounds_starting_tomorrow = Round.joins(:matches)
Expand Down
4 changes: 2 additions & 2 deletions app/views/v1/matches/_match.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
json.extract! match, :id, :kickoff_time, :status, :group_id, :next_match_id, :round_id, :location
json.extract! match, :id, :kickoff_time, :status, :group_id, :next_match_id, :round_id, :location, :minute
json.round_number match.round.number
json.team_home do
json.partial! match.team_home
Expand All @@ -11,7 +11,7 @@ end
json.team_away do
json.partial! match.team_away
if %w[finished started].include?(match[:status])
json.score match.team_away_score
json.score match.team_away_score
json.et_score match.team_away_et_score
json.ps_score match.team_away_ps_score
end
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20260607063338_add_minute_to_matches.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMinuteToMatches < ActiveRecord::Migration[6.1]
def change
add_column :matches, :minute, :integer
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions lib/tasks/match.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ namespace :match do
return 'Not allowed in production' if Rails.env.production?

@competition = Competition.last
completed_matches = @competition.matches.order(kickoff_time: :asc).first(5)
completed_matches.each do |match|
completed_matches = @competition.matches.order(kickoff_time: :asc).first(7)
completed_matches.each_with_index do |match, index|
Comment on lines 6 to +8
puts "#{match.team_home.name} (H) vs. #{match.team_away.name} (A)"
User.find_each do |user|
User.where(admin: true).each do |user|
prediction = Prediction.find_or_initialize_by(user: user, match: match)
prediction.choice = Prediction.choices.keys.sample
prediction.save
puts "- #{prediction.user.name} choose #{prediction.choice}"
end
match.finished!
if [5, 6].include?(index)
match.started!
match.minute = rand(1..90)
else
match.finished!
end
match.team_home_score = rand(0..3)
match.team_away_score = rand(0..3)
match.save
Expand Down