Skip to content

Commit

Permalink
Ignore previously matched live_times in Interactors::MatchLiveTimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Feb 16, 2018
1 parent addc31a commit 3e95b58
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/services/interactors/match_live_times.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def perform!
attr_reader :event, :live_times, :errors, :resources

def match_live_time_to_split_time(live_time)
split_time = live_time.absolute_time && event.split_times.where(match_attributes(live_time)).find { |st| st.day_and_time == live_time.absolute_time }
split_time = matching_split_time(live_time)
if split_time
live_time.update(split_time: split_time)
matched_live_times << live_time
Expand All @@ -39,6 +39,12 @@ def match_live_time_to_split_time(live_time)
end
end

def matching_split_time(live_time)
live_time.absolute_time &&
!live_time.matched? &&
event.split_times.where(match_attributes(live_time)).find { |st| st.day_and_time == live_time.absolute_time }
end

def match_attributes(live_time)
attributes = {split: live_time.split, bitkey: live_time.bitkey}
attributes[:pacer] = live_time.with_pacer unless live_time.with_pacer.nil?
Expand Down

0 comments on commit 3e95b58

Please sign in to comment.