I literally spent 5 hours reading the season update script over and over again before I recognised there were two bugs:
- I hadn't imagined a circumstance where a driver would miss race 1 and join for race 2, which happened last night. This meant that for race 1, the driver was assigned a finishing position of 0 - umm what? This threw an error in the points calculations and blew up the machine, giving every 0 points. I added a line of code to exclude any drivers with position = 0 from the calculations and boom - she's working again. One line of code that took 4 hours to write
- We have so many different ways a driver can earn points and so many different breakdowns of the league tables (all of the different car classes GT3, GT4, CUP, ST, driver classes PRO, SILVER, AM, cup types Sprint, Enduro and ICGT and all possible permutations and combinations). The final thing that was making all of the calculations break was a points and position counter reset for the different car classes. I just needed to add one clause to make sure it was resetting appropriately for each driver and it fixed everything. 1 further hour for half a line of code.
- #joyofcoding.