Archived
4
2

Next free slot algorithm now in TT² form

templates/content-index.tpl.html: Now contains TT² code and an in-built
    query to determine the next free slot. No need for an external
    query. Old code that used to use this has been deleted.

templates/queries-index-mysql.tpl.html,
templates/queries-index-sqlite.tpl.html: Old queries called
    'query_next_available_episode' removed since no longer needed.
This commit is contained in:
Dave Morriss 2023-10-29 17:32:02 +00:00
parent 8325b2c0d1
commit 097b50b30b
3 changed files with 0 additions and 67 deletions

View File

@ -30,9 +30,6 @@
</header>
<!--% days_till_next_episode = 0 %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--%# FOREACH next_available_episode_result IN DBI.query(query_next_available_episode) %-->
<!--%# days_till_next_episode = next_available_episode_result.delta_days %-->
<!--%# END %-->
<!--% USE date %-->
<!--% calc = date.calc %-->
<!--% episodes = DBI.query("SELECT id, date FROM eps WHERE date >= date('now') ORDER BY id").get_all() %-->

View File

@ -1,35 +1,3 @@
<!--
- <!--% query_next_available_episode = '
- WITH RECURSIVE
- min_id AS (
- SELECT max(id) AS start_id FROM eps WHERE date <= NOW()
- ),
- max_id AS (
- SELECT max(id) AS end_id FROM eps
- ),
- cnt(x) AS (
- SELECT start_id from min_id
- UNION ALL
- SELECT x+1 FROM cnt
- WHERE x+1 <= (SELECT end_id FROM max_id)
- ),
- first_empty AS (
- SELECT
- cnt.x AS id
- FROM cnt
- LEFT JOIN eps e ON cnt.x = e.id
- WHERE e.id IS NULL
- )
- SELECT
- fe.id as next_id,
- (SELECT DATE(ADDDATE(e2.date,1)) from eps e2 where e2.id = fe.id-1) as next_date,
- DATEDIFF((SELECT ADDDATE(e3.date,1) from eps e3 where e3.id = fe.id-1),now()) AS delta_days
- FROM first_empty AS fe
- LEFT JOIN eps e1 ON fe.id = e1.id
- LIMIT 1
- '
- %-->
-->
<!--% query_latest_episodes = '
WITH comment_tallies AS (
SELECT

View File

@ -1,35 +1,3 @@
<!--
- <!--% query_next_available_episode = '
- WITH RECURSIVE
- min_id AS (
- SELECT max(id) AS start_id FROM eps WHERE date <= date(\'now\')
- ),
- max_id AS (
- SELECT max(id) AS end_id FROM eps
- ),
- cnt(x) AS (
- SELECT start_id from min_id
- UNION ALL
- SELECT x+1 FROM cnt
- WHERE x+1 <= (SELECT end_id FROM max_id)
- ),
- first_empty AS (
- SELECT
- cnt.x AS id
- FROM cnt
- LEFT JOIN eps e ON cnt.x = e.id
- WHERE e.id IS NULL
- )
- SELECT
- fe.id as next_id,
- (SELECT date(eps.date,\'+1 day\') from eps where id = fe.id-1) as next_date,
- printf(\'%i\',abs(julianday((SELECT date(eps.date,\'+1 day\') from eps where id = fe.id-1)) - julianday(\'now\') + 1)) AS delta_days
- FROM first_empty AS fe
- LEFT JOIN eps e ON fe.id = e.id
- LIMIT 1
- '
- %-->
-->
<!--% query_latest_episodes = '
WITH comment_tallies AS (
SELECT