From e7fe824302d4dde1b385542c7a7ce8b31f90c6e4 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Thu, 18 May 2023 09:04:04 -0400 Subject: [PATCH] Fix calculation of the days until next available episode timeslot Do all date calulation in DB instead of naively adding 1 to the day that is returned. --- templates/content-index.tpl.html | 2 +- templates/queries-index-mysql.tpl.html | 6 +++--- templates/queries-index-sqlite.tpl.html | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/content-index.tpl.html b/templates/content-index.tpl.html index c6491f5..e6d66fa 100644 --- a/templates/content-index.tpl.html +++ b/templates/content-index.tpl.html @@ -34,7 +34,7 @@ %--> - + diff --git a/templates/queries-index-mysql.tpl.html b/templates/queries-index-mysql.tpl.html index 120b936..5c15dfe 100644 --- a/templates/queries-index-mysql.tpl.html +++ b/templates/queries-index-mysql.tpl.html @@ -6,9 +6,9 @@ ) SELECT MIN(next_id.id_next) AS \'next_id\', - 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\' + 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 diff --git a/templates/queries-index-sqlite.tpl.html b/templates/queries-index-sqlite.tpl.html index 1029b05..d855ba0 100644 --- a/templates/queries-index-sqlite.tpl.html +++ b/templates/queries-index-sqlite.tpl.html @@ -6,9 +6,9 @@ ) 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\' + 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