Convert index page queries from SQLite to MySQL

This commit is contained in:
Roan Horning 2022-10-20 23:24:56 -04:00
parent be1344e10c
commit aad77f3c78
Signed by: rho_n
GPG Key ID: 234AEF20B72D5769

View File

@ -10,15 +10,16 @@
<!--% days_till_next_episode = 0 %-->
<!--% USE DBI(constants.driver, constants.user, constants.password) %-->
<!--% FOREACH next_available_episode_result IN DBI.query('
WITH next_id AS (SELECT id, id + 1 AS \'id_next\', date as \'last_date\'
WITH next_id AS (
SELECT id, id + 1 AS \'id_next\', date as \'last_date\'
FROM eps
WHERE eps.date > date(\'now\')
WHERE eps.date > NOW()
)
SELECT
MIN(next_id.id_next) AS \'next_id\',
strftime(\'%Y\', MIN (last_date)) AS \'last_year\',
strftime(\'%d\', MIN (last_date)) AS \'last_day\',
strftime(\'%m\', MIN (last_date)) AS \'last_month\'
DATE_FORMAT(MIN(last_date), \'%Y\') AS \'last_year\',
DATE_FORMAT(MIN(last_date), \'%d\') AS \'last_day\',
DATE_FORMAT(MIN(last_date), \'%m\') AS \'last_month\'
FROM next_id
LEFT JOIN eps ON next_id.id_next = eps.id
WHERE eps.id IS NULL
@ -65,8 +66,8 @@
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\', \'+1 days\')
ORDER BY eps.id + 0 DESC
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY)
ORDER BY eps.id DESC
LIMIT 10
')
%-->
@ -106,8 +107,8 @@
FROM eps
INNER JOIN hosts ON eps.hostid = hosts.hostid
INNER JOIN miniseries ON eps.series = miniseries.id
WHERE eps.date < date(\'now\', \'+1 days\')
ORDER BY eps.id + 0 DESC
WHERE eps.date < DATE_ADD(NOW(), INTERVAL 1 DAY)
ORDER BY eps.id DESC
LIMIT 30 OFFSET 10
')
%-->