Skip to content

Commit

Permalink
fix(schedule): support days without any shows (#381)
Browse files Browse the repository at this point in the history
Previously, these would crash with "PANIC: runtime error: index out of range [-1]", which is not good.
  • Loading branch information
ashhhleyyy authored Sep 22, 2024
1 parent 124d834 commit 7cc5bbe
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions models/schedule_tabulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,20 @@ func buildList(schedule []*ScheduleItem, dates []time.Time) []WeekScheduleList {
days[dayIndex].Shows = append(days[dayIndex].Shows, *item)
}
}
for day := range days {
// Where does the come from, nobody knows; here's a fix to get rid of it though -ash (2024)
// TODO: actually fix this
// it comes from makescheduleslice see the s.fill line. needed otherwise the first show on monday will start at 6am on table view
// or not, theres jukeboxes coming from elsewhere aswell
if days[day].Shows[len(days[day].Shows)-1].IsSustainer(){
days[day].Shows = days[day].Shows[:len(days[day].Shows) - 1]
}
if days[day].Shows[0].IsSustainer(){
days[day].Shows = days[day].Shows[1:]
}
}
for day := range days {
// Where does the come from, nobody knows; here's a fix to get rid of it though -ash (2024)
// TODO: actually fix this
// it comes from makescheduleslice see the s.fill line. needed otherwise the first show on monday will start at 6am on table view
// or not, theres jukeboxes coming from elsewhere aswell
if len(days[day].Shows) > 0 {
if days[day].Shows[len(days[day].Shows)-1].IsSustainer(){
days[day].Shows = days[day].Shows[:len(days[day].Shows) - 1]
}
if days[day].Shows[0].IsSustainer(){
days[day].Shows = days[day].Shows[1:]
}
}
}
return days
}

Expand Down

0 comments on commit 7cc5bbe

Please sign in to comment.