2022-11-27 18:54:14 +00:00
|
|
|
<!--% query_next_available_episode = '
|
2023-10-10 16:55:44 +00:00
|
|
|
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,
|
|
|
|
DATEDIFF(ADDDATE(prev_date,date_offset),NOW()) AS delta_days
|
|
|
|
FROM free_slot
|
2022-11-27 18:54:14 +00:00
|
|
|
'
|
|
|
|
%-->
|
|
|
|
<!--% query_latest_episodes = '
|
2023-10-10 16:55:44 +00:00
|
|
|
WITH comment_tallies AS (
|
|
|
|
SELECT
|
2022-11-27 18:54:14 +00:00
|
|
|
eps_id,
|
|
|
|
COUNT(eps_id) AS eps_tally
|
|
|
|
FROM comments
|
2023-10-10 16:55:44 +00:00
|
|
|
GROUP BY eps_id
|
2022-11-27 18:54:14 +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,
|
2022-11-27 18:54:14 +00:00
|
|
|
eps.notes,
|
|
|
|
hosts.local_image,
|
2023-10-10 16:55:44 +00:00
|
|
|
hosts.hostid,
|
2022-11-27 18:54:14 +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
|
2022-11-27 18:54:14 +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 <= UTC_DATE()
|
2023-10-10 16:55:44 +00:00
|
|
|
ORDER BY eps.id DESC
|
2022-11-27 18:54:14 +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,
|
2022-11-27 18:54:14 +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,
|
2022-11-27 18:54:14 +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
|
2022-11-27 18:54:14 +00:00
|
|
|
INNER JOIN miniseries ON eps.series = miniseries.id
|
2023-07-23 16:03:27 +00:00
|
|
|
WHERE eps.date <= UTC_DATE()
|
2022-11-27 18:54:14 +00:00
|
|
|
ORDER BY eps.id DESC
|
|
|
|
LIMIT 30 OFFSET 10
|
|
|
|
'
|
|
|
|
%-->
|
|
|
|
|