79 lines
2.2 KiB
HTML
79 lines
2.2 KiB
HTML
<!--
|
|
- <!--% 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
|
|
eps_id,
|
|
COUNT(eps_id) AS eps_tally
|
|
FROM comments
|
|
GROUP BY eps_id
|
|
)
|
|
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.host, hosts.email,
|
|
miniseries.name AS series, miniseries.id AS seriesid,
|
|
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
|
|
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,
|
|
eps.duration, eps.notes, eps.tags,
|
|
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
|
|
INNER JOIN miniseries ON eps.series = miniseries.id
|
|
WHERE eps.date <= UTC_DATE()
|
|
ORDER BY eps.id DESC
|
|
LIMIT 30 OFFSET 10
|
|
'
|
|
%-->
|
|
|