Archived
4
2

Merge pull request 'Fixing days to next free slot' (#174) from fix_next_available_episode into main

Reviewed-on: #174
This commit is contained in:
Dave Morriss 2023-10-10 19:43:45 +00:00
commit 51d328203b
3 changed files with 102 additions and 74 deletions

View File

@ -26,17 +26,15 @@
<hr> <hr>
<article> <article>
<header> <header>
<h3>Welcome to HPR the Community Podcast</h3> <h3>Welcome to HPR, the Community Podcast</h3>
</header> </header>
<!--% days_till_next_episode = 0 %--> <!--% days_till_next_episode = 0 %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %--> <!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% FOREACH next_available_episode_result IN DBI.query(query_next_available_episode) <!--% FOREACH next_available_episode_result IN DBI.query(query_next_available_episode) %-->
%--> <!--% days_till_next_episode = next_available_episode_result.delta_days %-->
<!--% USE date %-->
<!--% calc = date.calc %-->
<!--% days_till_next_episode = calc.Delta_Days(date.format(date.now, '%Y'),date.format(date.now, '%m'),date.format(date.now, '%d'),next_available_episode_result.last_year,next_available_episode_result.last_month,next_available_episode_result.last_day) %-->
<!--% END %--> <!--% END %-->
<!--% USE date %--> <!--% USE date %-->
<!--% calc = date.calc %-->
<!--% delta = date.calc.N_Delta_YMD(2005,9,19, date.format(date.now, '%Y'),date.format(date.now, '%m'),date.format(date.now, '%d')) %--> <!--% delta = date.calc.N_Delta_YMD(2005,9,19, date.format(date.now, '%Y'),date.format(date.now, '%m'),date.format(date.now, '%d')) %-->
<p>We started producing shows as <a href="<!--% absolute_path(baseurl) %-->eps/index.html#twat_episodes"><em>Today with a Techie</em></a> on 2005-09-19, <!--% delta.0 %--> years, <!--% delta.1 %--> months, <!--% delta.2 %--> days ago. our shows are produced by <a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">listeners</a> like you and can be on any <a href="<!--% absolute_path(baseurl) %-->eps/index.html">topic</a> that <strong>"are of interest to <a href="https://en.wikipedia.org/wiki/hacker_(hobbyist)">hackers</a>"</strong>. If you listen to HPR then please consider contributing one show a year. if you <a href="<!--% absolute_url(baseurl) %-->about.html#so_you_want_to_record_a_podcast">record</a> your show now it could be <a href="<!--% hub_baseurl %-->calendar.php">released</a> in <strong><!--% days_till_next_episode %--></strong> days.</p> <p>We started producing shows as <a href="<!--% absolute_path(baseurl) %-->eps/index.html#twat_episodes"><em>Today with a Techie</em></a> on 2005-09-19, <!--% delta.0 %--> years, <!--% delta.1 %--> months, <!--% delta.2 %--> days ago. our shows are produced by <a href="<!--% absolute_path(baseurl) %-->correspondents/index.html">listeners</a> like you and can be on any <a href="<!--% absolute_path(baseurl) %-->eps/index.html">topic</a> that <strong>"are of interest to <a href="https://en.wikipedia.org/wiki/hacker_(hobbyist)">hackers</a>"</strong>. If you listen to HPR then please consider contributing one show a year. if you <a href="<!--% absolute_url(baseurl) %-->about.html#so_you_want_to_record_a_podcast">record</a> your show now it could be <a href="<!--% hub_baseurl %-->calendar.php">released</a> in <strong><!--% days_till_next_episode %--></strong> days.</p>
</article> </article>

View File

@ -1,17 +1,32 @@
<!--% query_next_available_episode = ' <!--% query_next_available_episode = '
WITH next_id AS ( WITH next_id AS (
SELECT id, id + 1 AS \'id_next\', date as \'last_date\' SELECT id, id + 1 AS id_next, date as last_date
FROM eps FROM eps
WHERE eps.date > NOW() WHERE eps.date > NOW()
) ),
free_slot AS (
SELECT SELECT
MIN(next_id.id_next) AS \'next_id\', last_date AS prev_date,
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%Y\') AS \'last_year\', CASE
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%d\') AS \'last_day\', WHEN DAYOFWEEK(last_date) = 6
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%m\') AS \'last_month\' THEN 3
ELSE 1
END AS date_offset,
next_id.id_next AS empty_slot
FROM next_id FROM next_id
LEFT JOIN eps ON next_id.id_next = eps.id LEFT JOIN eps ON next_id.id_next = eps.id
WHERE eps.id IS NULL WHERE eps.id IS NULL
ORDER BY next_id.id
LIMIT 1
)
SELECT
empty_slot AS next_id,
ADDDATE(prev_date,date_offset) AS next_date,
YEAR(ADDDATE(prev_date,date_offset)) AS last_year,
MONTH(ADDDATE(prev_date,date_offset)) AS last_month,
DAY(ADDDATE(prev_date,date_offset)) AS last_day,
DATEDIFF(ADDDATE(prev_date,date_offset),NOW()) AS delta_days
FROM free_slot
' '
%--> %-->
<!--% query_latest_episodes = ' <!--% query_latest_episodes = '

View File

@ -1,17 +1,32 @@
<!--% query_next_available_episode = ' <!--% query_next_available_episode = '
WITH next_id AS ( WITH next_id AS (
SELECT id, id + 1 AS \'id_next\', date as \'last_date\' SELECT id, id + 1 AS id_next, date as last_date
FROM eps FROM eps
WHERE eps.date > date(\'now\') WHERE eps.date > date(\'now\')
) ),
free_slot AS (
SELECT SELECT
MIN(next_id.id_next) AS \'next_id\', last_date AS prev_date,
strftime(\'%Y\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_year\', CASE
strftime(\'%d\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_day\', WHEN strftime(\'%w\',last_date) = \'5\'
strftime(\'%m\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_month\' THEN \'+3 days\'
ELSE \'+1 days\'
END AS date_offset,
next_id.id_next AS empty_slot
FROM next_id FROM next_id
LEFT JOIN eps ON next_id.id_next = eps.id LEFT JOIN eps ON next_id.id_next = eps.id
WHERE eps.id IS NULL WHERE eps.id IS NULL
ORDER BY next_id.id
LIMIT 1
)
SELECT
empty_slot AS next_id,
DATE (prev_date, date_offset) AS next_date,
strftime(\'%Y\', DATE (prev_date, date_offset)) AS last_year,
strftime(\'%m\', DATE (prev_date, date_offset)) AS last_month,
strftime(\'%d\', DATE (prev_date, date_offset)) AS last_day,
printf(\'%i\',abs(julianday(DATE (prev_date, date_offset)) - julianday(\'now\') + 1)) AS delta_days
FROM free_slot
' '
%--> %-->
<!--% query_latest_episodes = ' <!--% query_latest_episodes = '