Skip to content

Commit

Permalink
event for livetiming get prev and next even if given number does not …
Browse files Browse the repository at this point in the history
…exist
  • Loading branch information
konrad2002 committed Aug 17, 2023
1 parent f05d78e commit 61070f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions service/event_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func GetEventByMeetingAndNumberForLivetiming(id string, number int) (dto.EventLi

var eventLivetiming dto.EventLivetimingDto

found := false
for i := 0; i < len(events); i++ {
if events[i].Number == number {
eventLivetiming.Event = events[i]
Expand All @@ -103,8 +104,21 @@ func GetEventByMeetingAndNumberForLivetiming(id string, number int) (dto.EventLi
if i < len(events)-1 {
eventLivetiming.NextEvent = events[i+1]
}
found = true
break
}
if events[i].Number > number {
eventLivetiming.NextEvent = events[i]
if i > 0 {
eventLivetiming.PrevEvent = events[i-1]
}
found = true
break
}
}

if !found {
eventLivetiming.PrevEvent = events[len(events)-1]
}

return eventLivetiming, nil
Expand Down

0 comments on commit 61070f7

Please sign in to comment.