A further fix to the free slot algorithm
templates/content-index.tpl.html: the `TT²` algorithm can be simplified because the new query returns less. We get the date of the show before the free slot, and can increment it differently depending on whether the previous show is on a Friday or not - catering for weekends in other words! templates/queries-index-mysql.tpl.html, templates/queries-index-sqlite.tpl.html: using a 'find unused index numbers' query available in many places on the Internet, but modified to return the id number and date for the show *before* the next free slot.
This commit is contained in:
parent
0ef92840c8
commit
e5b5aac104
@ -32,13 +32,8 @@
|
||||
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
|
||||
<!--% USE date %-->
|
||||
<!--% calc = date.calc %-->
|
||||
<!--% episodes = DBI.query("SELECT id, date FROM eps WHERE date >= date('now') ORDER BY id").get_all() %-->
|
||||
<!--% ind = episodes.0.id %-->
|
||||
<!--% FOREACH ep IN episodes %-->
|
||||
<!--% LAST IF ep.id != ind %-->
|
||||
<!--% last_date = ep.date.split('-') %-->
|
||||
<!--% ind = ind+1 %-->
|
||||
<!--% END %-->
|
||||
<!--% episodes = DBI.query(query_next_available_episode).get_all() %-->
|
||||
<!--% last_date = episodes.0.date.split('-') %-->
|
||||
<!--% offset = (calc.Day_of_Week(last_date.0,last_date.1,last_date.2) == 5 ? 3 : 1) %-->
|
||||
<!--% slot_date = calc.Add_Delta_Days(last_date.0,last_date.1,last_date.2,offset) %-->
|
||||
<!--% now = calc.Today() %-->
|
||||
|
@ -1,3 +1,15 @@
|
||||
<!--% query_next_available_episode = '
|
||||
SELECT id, date FROM eps e WHERE id = (
|
||||
SELECT id + 1 FROM eps mo
|
||||
WHERE NOT EXISTS (
|
||||
SELECT NULL
|
||||
FROM eps mi
|
||||
WHERE mi.id = mo.id + 1
|
||||
)
|
||||
ORDER BY id
|
||||
LIMIT 1) - 1
|
||||
'
|
||||
%-->
|
||||
<!--% query_latest_episodes = '
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
|
@ -1,3 +1,15 @@
|
||||
<!--% query_next_available_episode = '
|
||||
SELECT id, date FROM eps e WHERE id = (
|
||||
SELECT id + 1 FROM eps mo
|
||||
WHERE NOT EXISTS (
|
||||
SELECT NULL
|
||||
FROM eps mi
|
||||
WHERE mi.id = mo.id + 1
|
||||
)
|
||||
ORDER BY id
|
||||
LIMIT 1) - 1
|
||||
'
|
||||
%-->
|
||||
<!--% query_latest_episodes = '
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
|
Reference in New Issue
Block a user