Simplify host episode counting code

Use the database to count the episodes.
See https://stackoverflow.com/questions/1656748/how-can-i-fetch-a-single-count-value-from-a-database-with-dbi
for explanation of Perl DBI calls.
This commit is contained in:
2025-11-06 20:52:43 -05:00
parent 192d994556
commit 126e184126
2 changed files with 14 additions and 19 deletions

View File

@@ -3,22 +3,17 @@
<!--% PROCESS 'shared-utils.tpl.html' %-->
<!--% PROCESS "queries-correspondent.tpl.html" %-->
<!--% USE DBI(constants.driver) %-->
<!--% results_hpr_shows = DBI.prepare(query_hpr_shows)
%-->
<!--% results_hpr_shows = DBI.prepare(query_hpr_shows) %-->
<!--% results_hpr_show_count = DBI.prepare(query_hpr_show_count) %-->
<!--% hpr_shows_to_count = results_hpr_show_count.execute(id); %-->
<!--% hpr_result_status = results_hpr_show_count.execute(id); %-->
<!--% hpr_shows = results_hpr_shows.execute(id); %-->
<!--% hpr_show_count = 0 %-->
<!--% FOREACH show IN hpr_shows_to_count %-->
<!--% hpr_show_count = hpr_show_count +1; %-->
<!--% END %-->
<!--% hpr_show_count = results_hpr_show_count.fetchrow_array %-->
<!--% twt_shows_to_count = query_twt_show_count.execute(id); %-->
<!--% twt_shows = query_twt_shows.execute(id); %-->
<!--% twt_show_count = 0 %-->
<!--% FOREACH show IN twt_shows_to_count %-->
<!--% twt_show_count = twt_show_count +1; %-->
<!--% END %-->
<!--% results_hpr_shows = DBI.prepare(query_twt_shows) %-->
<!--% results_twt_show_count = DBI.prepare(query_twt_show_count) %-->
<!--% twt_result_status = results_twt_show_count.execute(id); %-->
<!--% twt_shows = results_hpr_shows.execute(id); %-->
<!--% twt_show_count = results_twt_show_count.fetchrow_array %-->
<!--% hosts = DBI.tie('hosts', 'hostid') %-->

View File

@@ -17,18 +17,18 @@
'
%-->
<!--% query_hpr_show_count = '
SELECT id
SELECT COUNT(id) as Tally
FROM eps
WHERE eps.hostid = ? AND eps.date < date(\'now\', \'+1 days\')
'
%-->
<!--% query_twt_show_count = DBI.prepare('
SELECT id
<!--% query_twt_show_count = '
SELECT COUNT(id) as Tally
FROM twat_eps AS eps
WHERE eps.hostid = ?
')
'
%-->
<!--% query_twt_shows = DBI.prepare('
<!--% query_twt_shows = '
SELECT
eps.id,
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
@@ -44,6 +44,6 @@
INNER JOIN miniseries ON eps.series = miniseries.id
WHERE hosts.hostid = ?
ORDER BY eps.id DESC
')
'
%-->