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:
commit
51d328203b
@ -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)
|
||||
%-->
|
||||
<!--% 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 %-->
|
||||
<!--% 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 %-->
|
||||
<!--% USE date %-->
|
||||
<!--% 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>
|
||||
@ -54,7 +52,7 @@
|
||||
<h3><!--% latest_episodes.summary%--></h3>
|
||||
<p class="meta"$><!--% show_avatar(latest_episodes.hostid, latest_episodes.host, host_cnt) %-->
|
||||
Hosted by <a href="<!--% absolute_path(baseurl) %-->correspondents/<!--% zero_pad_left(latest_episodes.hostid) %-->.html"><!--% latest_episodes.host %--></a> on <!--% latest_episodes.date %--> is flagged as <!--% display_explicit(latest_episodes.explicit) %--> and released under a <!--% latest_episodes.license %--> license. <br>
|
||||
<!--% display_tags(latest_episodes.tags) %-->
|
||||
<!--% display_tags(latest_episodes.tags) %-->
|
||||
<span><!--% show_series(latest_episodes.series, latest_episodes.seriesid) %--></span>
|
||||
<span><label>Comments: </label><!--% display_comments_tally(latest_episodes.id, latest_episodes.eps_tally) %--></span><br>
|
||||
<!--% listen_now(latest_episodes, "hpr", baseurl, media_baseurl) %-->
|
||||
@ -72,7 +70,7 @@
|
||||
<hr>
|
||||
<h1>Previous five weeks</h1>
|
||||
</header>
|
||||
<!--% FOREACH last_5_weeks_episodes IN DBI.query(query_last_5_weeks_episodes)
|
||||
<!--% FOREACH last_5_weeks_episodes IN DBI.query(query_last_5_weeks_episodes)
|
||||
%-->
|
||||
<!--% show_summary(last_5_weeks_episodes) %-->
|
||||
<p class="listen-in"><!--% display_listen_in(last_5_weeks_episodes.id) %--></p>
|
||||
|
@ -1,58 +1,73 @@
|
||||
<!--% 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 = '
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
eps_id,
|
||||
COUNT(eps_id) AS eps_tally
|
||||
FROM comments
|
||||
GROUP BY eps_id
|
||||
GROUP BY eps_id
|
||||
)
|
||||
SELECT
|
||||
eps.id,
|
||||
eps.explicit,
|
||||
eps.date, eps.license, eps.duration,
|
||||
eps.title, eps.summary, eps.tags,
|
||||
SELECT
|
||||
eps.id,
|
||||
eps.explicit,
|
||||
eps.date, eps.license, eps.duration,
|
||||
eps.title, eps.summary, eps.tags,
|
||||
eps.notes,
|
||||
hosts.local_image,
|
||||
hosts.hostid,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email,
|
||||
miniseries.name AS series, miniseries.id AS seriesid,
|
||||
COALESCE (comment_tallies.eps_tally, 0) AS eps_tally
|
||||
FROM eps
|
||||
COALESCE (comment_tallies.eps_tally, 0) AS eps_tally
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
INNER JOIN miniseries ON eps.series = miniseries.id
|
||||
LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id
|
||||
WHERE eps.date <= UTC_DATE()
|
||||
ORDER BY eps.id DESC
|
||||
ORDER BY eps.id DESC
|
||||
LIMIT 10
|
||||
'
|
||||
%-->
|
||||
<!--% query_last_5_weeks_episodes = '
|
||||
SELECT
|
||||
eps.id,
|
||||
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
||||
eps.date, eps.license, eps.title, eps.summary,
|
||||
SELECT
|
||||
eps.id,
|
||||
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
||||
eps.date, eps.license, eps.title, eps.summary,
|
||||
eps.duration, eps.notes, eps.tags,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email, hosts.local_image,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email, hosts.local_image,
|
||||
miniseries.name AS series, miniseries.id AS seriesid
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
INNER JOIN miniseries ON eps.series = miniseries.id
|
||||
WHERE eps.date <= UTC_DATE()
|
||||
ORDER BY eps.id DESC
|
||||
|
@ -1,58 +1,73 @@
|
||||
<!--% 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 = '
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
WITH comment_tallies AS (
|
||||
SELECT
|
||||
eps_id,
|
||||
COUNT(eps_id) AS eps_tally
|
||||
FROM comments
|
||||
GROUP BY eps_id
|
||||
GROUP BY eps_id
|
||||
)
|
||||
SELECT
|
||||
eps.id,
|
||||
eps.explicit,
|
||||
eps.date, eps.license, eps.duration,
|
||||
eps.title, eps.summary, eps.tags,
|
||||
SELECT
|
||||
eps.id,
|
||||
eps.explicit,
|
||||
eps.date, eps.license, eps.duration,
|
||||
eps.title, eps.summary, eps.tags,
|
||||
eps.notes,
|
||||
hosts.local_image,
|
||||
hosts.hostid,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email,
|
||||
miniseries.name AS series, miniseries.id AS seriesid,
|
||||
COALESCE (comment_tallies.eps_tally, 0) AS eps_tally
|
||||
FROM eps
|
||||
COALESCE (comment_tallies.eps_tally, 0) AS eps_tally
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
INNER JOIN miniseries ON eps.series = miniseries.id
|
||||
LEFT JOIN comment_tallies ON eps.id = comment_tallies.eps_id
|
||||
WHERE eps.date <= date(\'now\')
|
||||
ORDER BY eps.id + 0 DESC
|
||||
ORDER BY eps.id + 0 DESC
|
||||
LIMIT 10
|
||||
'
|
||||
%-->
|
||||
<!--% query_last_5_weeks_episodes = '
|
||||
SELECT
|
||||
eps.id,
|
||||
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
||||
eps.date, eps.license, eps.title, eps.summary,
|
||||
SELECT
|
||||
eps.id,
|
||||
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
||||
eps.date, eps.license, eps.title, eps.summary,
|
||||
eps.duration, eps.notes, eps.tags,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email, hosts.local_image,
|
||||
hosts.hostid,
|
||||
hosts.host, hosts.email, hosts.local_image,
|
||||
miniseries.name AS series, miniseries.id AS seriesid
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
FROM eps
|
||||
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
||||
INNER JOIN miniseries ON eps.series = miniseries.id
|
||||
WHERE eps.date <= date(\'now\')
|
||||
ORDER BY eps.id + 0 DESC
|
||||
|
Reference in New Issue
Block a user