Computation of days to next free slot is incorrect on index page #173
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: rho_n/hpr_generator#173
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently (2023-10-06) the next free slot is 3966 on 2023-10-16. That's 10 days in the future.
The index page states:
This computation is made by using module
Date::Calc
on data from a database query. The query isquery_next_available_episode
intemplates/queries-index-{mysql,sqlite}.tpl.html
.This returns the show number (correct) and the date of the show (incorrect). When run today it returns the date for slot 3966 as 2023-10-14, so the delta date calculation returns 8, not 10.
The date/show finding query needs to be rewritten.
The original query was as follows (slightly edited for testing):
For the current situation on 2023-10-07 it returns:
Show 3966 is actually scheduled for 2023-10-16.
The first draft of a replacement query is this:
When run on the database it returns:
This is the correct date.
This replacement is somewhat more complex than the original with an extra CTE, but that simplifies the main query and computes the date offset. If the date before the next empty slot is a Friday (day 5 in the range used), the offset is 3 days to cater for the weekend, otherwise it's 1 day.
This hasn't been heavily tested yet, so will not be proposed as a fix until some testing has been done.
Tested this and the MySQL variant, and the change seems to solve the problem.
The
last_year
,last_month
andlast_month
fields are used incontent-index.tpl.html
to compute the number of days until the next empty slot usingDate::Calc
.The changes to the query permits it to compute this difference itself, so the computation in the TT² template is not needed.
Released the two files with the database queries as well as a new version of
content-index.tpl.html
without the computation. The changes were tested on copies of the live database and all worked as desired.The changes were merged into the repo.
Closing the issue.