2023-02-08 21:05:36 +00:00
|
|
|
<!--% query_next_available_episode = '
|
2023-10-16 22:01:30 +00:00
|
|
|
WITH RECURSIVE
|
|
|
|
min_id AS (
|
|
|
|
SELECT max(id) AS start_id FROM eps WHERE date <= date(\'now\')
|
2023-10-10 16:55:44 +00:00
|
|
|
),
|
2023-10-16 22:01:30 +00:00
|
|
|
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 (
|
2023-10-10 16:55:44 +00:00
|
|
|
SELECT
|
2023-10-16 22:01:30 +00:00
|
|
|
cnt.x AS id
|
|
|
|
FROM cnt
|
|
|
|
LEFT JOIN eps e ON cnt.x = e.id
|
|
|
|
WHERE e.id IS NULL
|
2023-10-10 16:55:44 +00:00
|
|
|
)
|
|
|
|
SELECT
|
2023-10-16 22:01:30 +00:00
|
|
|
fe.id as empty_slot,
|
|
|
|
(SELECT date(eps.date,\'+1 day\') from eps where id = fe.id-1) as slot_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
|
2023-02-08 21:05:36 +00:00
|
|
|
'
|
|
|
|
%-->
|
|
|
|
<!--% query_latest_episodes = '
|
2023-10-10 16:55:44 +00:00
|
|
|
WITH comment_tallies AS (
|
|
|
|
SELECT
|
2023-02-08 21:05:36 +00:00
|
|
|
eps_id,
|
|
|
|
COUNT(eps_id) AS eps_tally
|
|
|
|
FROM comments
|
2023-10-10 16:55:44 +00:00
|
|
|
GROUP BY eps_id
|
2023-02-08 21:05:36 +00:00
|
|
|
)
|
2023-10-10 16:55:44 +00:00
|
|
|
SELECT
|
|
|
|
eps.id,
|
|
|
|
eps.explicit,
|
|
|
|
eps.date, eps.license, eps.duration,
|
|
|
|
eps.title, eps.summary, eps.tags,
|
2023-02-08 21:05:36 +00:00
|
|
|
eps.notes,
|
|
|
|
hosts.local_image,
|
2023-10-10 16:55:44 +00:00
|
|
|
hosts.hostid,
|
2023-02-08 21:05:36 +00:00
|
|
|
hosts.host, hosts.email,
|
|
|
|
miniseries.name AS series, miniseries.id AS seriesid,
|
2023-10-10 16:55:44 +00:00
|
|
|
COALESCE (comment_tallies.eps_tally, 0) AS eps_tally
|
|
|
|
FROM eps
|
2023-02-08 21:05:36 +00:00
|
|
|
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
|
2023-07-23 16:03:27 +00:00
|
|
|
WHERE eps.date <= date(\'now\')
|
2023-10-10 16:55:44 +00:00
|
|
|
ORDER BY eps.id + 0 DESC
|
2023-02-08 21:05:36 +00:00
|
|
|
LIMIT 10
|
|
|
|
'
|
|
|
|
%-->
|
|
|
|
<!--% query_last_5_weeks_episodes = '
|
2023-10-10 16:55:44 +00:00
|
|
|
SELECT
|
|
|
|
eps.id,
|
|
|
|
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
|
|
|
eps.date, eps.license, eps.title, eps.summary,
|
2023-02-08 21:05:36 +00:00
|
|
|
eps.duration, eps.notes, eps.tags,
|
2023-10-10 16:55:44 +00:00
|
|
|
hosts.hostid,
|
|
|
|
hosts.host, hosts.email, hosts.local_image,
|
2023-02-08 21:05:36 +00:00
|
|
|
miniseries.name AS series, miniseries.id AS seriesid
|
2023-10-10 16:55:44 +00:00
|
|
|
FROM eps
|
|
|
|
INNER JOIN hosts ON eps.hostid = hosts.hostid
|
2023-02-08 21:05:36 +00:00
|
|
|
INNER JOIN miniseries ON eps.series = miniseries.id
|
2023-07-23 16:03:27 +00:00
|
|
|
WHERE eps.date <= date(\'now\')
|
2023-02-08 21:05:36 +00:00
|
|
|
ORDER BY eps.id + 0 DESC
|
|
|
|
LIMIT 30 OFFSET 10
|
|
|
|
'
|
|
|
|
%-->
|
|
|
|
|