UniversityRadioYork / MyRadio

University Radio York's back-end radio management system
https://ury.org.uk/myradio
16 stars 16 forks source link

CoreUtils::getAcademicYear() misidentifying 2022-23 #1105

Open markspolakovs opened 1 year ago

markspolakovs commented 1 year ago

Given this data in the terms table:

start                               descr   finish                              termid
2022-09-26 00:00:00.000000 +00:00   Autumn  2022-12-05 00:00:00.000000 +00:00   66
2023-01-09 00:00:00.000000 +00:00   Spring  2023-03-20 00:00:00.000000 +00:00   67
2023-04-17 00:00:00.000000 +00:00   Summer  2023-06-26 00:00:00.000000 +00:00   68

CoreUtils::getAcademicYear() returns 2023, not 2022.


The query it runs is

SELECT start FROM public.terms WHERE descr='Autumn'
AND EXTRACT(year FROM start) = $1

where $1 is the current calendar year (date('Y')) in PHP. This returns no rows, because there's no record for the 2023 Autumn Term (because of semesterisation). As such MyRadio defaults to the current year (if there were an autumn term row it'd pick 2022 unless the first day of term was within 49 days).

The simple fix would be to insert a row for it, however this will need revising in September, so I'm wondering if we can do better here.