Fixing days to next free slot
templates/queries-index-mysql.tpl.html, templates/queries-index-sqlite.tpl.html: Enhanced the query that finds the next free slot (query_next_available_episode). Also made it compute the days to the slot from the current day. The query returns data for calling Date::Calc to compute the number of days, but this calculation is no longer necessary. Next release will remove this. templates/content-index.tpl.html: The number of days to the next free slot is reported here. The original Date::Calc computation which did this is no longer needed and has been removed since the query (query_next_available_episode) does it.
This commit is contained in:
parent
faac8c202e
commit
366729a827
@ -26,17 +26,15 @@
|
||||
<hr>
|
||||
<article>
|
||||
<header>
|
||||
<h3>Welcome to HPR the Community Podcast</h3>
|
||||
<h3>Welcome to HPR, the Community Podcast</h3>
|
||||
</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)
|
||||
%-->
|
||||
<!--% 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) %-->
|
||||
<!--% 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 %-->
|
||||
<!--% 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>
|
||||
</article>
|
||||
|
@ -1,17 +1,32 @@
|
||||
<!--% query_next_available_episode = '
|
||||
WITH next_id AS (
|
||||
SELECT id, id + 1 AS \'id_next\', date as \'last_date\'
|
||||
FROM eps
|
||||
WHERE eps.date > NOW()
|
||||
)
|
||||
SELECT
|
||||
MIN(next_id.id_next) AS \'next_id\',
|
||||
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%Y\') AS \'last_year\',
|
||||
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%d\') AS \'last_day\',
|
||||
DATE_FORMAT(DATE_ADD(MIN(last_date), INTERVAL 1 DAY), \'%m\') AS \'last_month\'
|
||||
FROM next_id
|
||||
LEFT JOIN eps ON next_id.id_next = eps.id
|
||||
WHERE eps.id IS NULL
|
||||
WITH next_id AS (
|
||||
SELECT id, id + 1 AS id_next, date as last_date
|
||||
FROM eps
|
||||
WHERE eps.date > NOW()
|
||||
),
|
||||
free_slot AS (
|
||||
SELECT
|
||||
last_date AS prev_date,
|
||||
CASE
|
||||
WHEN DAYOFWEEK(last_date) = 6
|
||||
THEN 3
|
||||
ELSE 1
|
||||
END AS date_offset,
|
||||
next_id.id_next AS empty_slot
|
||||
FROM next_id
|
||||
LEFT JOIN eps ON next_id.id_next = eps.id
|
||||
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 = '
|
||||
|
@ -1,17 +1,32 @@
|
||||
<!--% query_next_available_episode = '
|
||||
WITH next_id AS (
|
||||
SELECT id, id + 1 AS \'id_next\', date as \'last_date\'
|
||||
FROM eps
|
||||
WHERE eps.date > date(\'now\')
|
||||
)
|
||||
SELECT
|
||||
MIN(next_id.id_next) AS \'next_id\',
|
||||
strftime(\'%Y\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_year\',
|
||||
strftime(\'%d\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_day\',
|
||||
strftime(\'%m\', DATE (MIN (last_date), \'+1 Days\')) AS \'last_month\'
|
||||
FROM next_id
|
||||
LEFT JOIN eps ON next_id.id_next = eps.id
|
||||
WHERE eps.id IS NULL
|
||||
WITH next_id AS (
|
||||
SELECT id, id + 1 AS id_next, date as last_date
|
||||
FROM eps
|
||||
WHERE eps.date > date(\'now\')
|
||||
),
|
||||
free_slot AS (
|
||||
SELECT
|
||||
last_date AS prev_date,
|
||||
CASE
|
||||
WHEN strftime(\'%w\',last_date) = \'5\'
|
||||
THEN \'+3 days\'
|
||||
ELSE \'+1 days\'
|
||||
END AS date_offset,
|
||||
next_id.id_next AS empty_slot
|
||||
FROM next_id
|
||||
LEFT JOIN eps ON next_id.id_next = eps.id
|
||||
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 = '
|
||||
|
Reference in New Issue
Block a user