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:
@@ -3,22 +3,17 @@
|
|||||||
<!--% PROCESS 'shared-utils.tpl.html' %-->
|
<!--% PROCESS 'shared-utils.tpl.html' %-->
|
||||||
<!--% PROCESS "queries-correspondent.tpl.html" %-->
|
<!--% PROCESS "queries-correspondent.tpl.html" %-->
|
||||||
<!--% USE DBI(constants.driver) %-->
|
<!--% 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) %-->
|
<!--% 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_shows = results_hpr_shows.execute(id); %-->
|
||||||
<!--% hpr_show_count = 0 %-->
|
<!--% hpr_show_count = results_hpr_show_count.fetchrow_array %-->
|
||||||
<!--% FOREACH show IN hpr_shows_to_count %-->
|
|
||||||
<!--% hpr_show_count = hpr_show_count +1; %-->
|
|
||||||
<!--% END %-->
|
|
||||||
|
|
||||||
<!--% twt_shows_to_count = query_twt_show_count.execute(id); %-->
|
<!--% results_hpr_shows = DBI.prepare(query_twt_shows) %-->
|
||||||
<!--% twt_shows = query_twt_shows.execute(id); %-->
|
<!--% results_twt_show_count = DBI.prepare(query_twt_show_count) %-->
|
||||||
<!--% twt_show_count = 0 %-->
|
<!--% twt_result_status = results_twt_show_count.execute(id); %-->
|
||||||
<!--% FOREACH show IN twt_shows_to_count %-->
|
<!--% twt_shows = results_hpr_shows.execute(id); %-->
|
||||||
<!--% twt_show_count = twt_show_count +1; %-->
|
<!--% twt_show_count = results_twt_show_count.fetchrow_array %-->
|
||||||
<!--% END %-->
|
|
||||||
|
|
||||||
<!--% hosts = DBI.tie('hosts', 'hostid') %-->
|
<!--% hosts = DBI.tie('hosts', 'hostid') %-->
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,18 @@
|
|||||||
'
|
'
|
||||||
%-->
|
%-->
|
||||||
<!--% query_hpr_show_count = '
|
<!--% query_hpr_show_count = '
|
||||||
SELECT id
|
SELECT COUNT(id) as Tally
|
||||||
FROM eps
|
FROM eps
|
||||||
WHERE eps.hostid = ? AND eps.date < date(\'now\', \'+1 days\')
|
WHERE eps.hostid = ? AND eps.date < date(\'now\', \'+1 days\')
|
||||||
'
|
'
|
||||||
%-->
|
%-->
|
||||||
<!--% query_twt_show_count = DBI.prepare('
|
<!--% query_twt_show_count = '
|
||||||
SELECT id
|
SELECT COUNT(id) as Tally
|
||||||
FROM twat_eps AS eps
|
FROM twat_eps AS eps
|
||||||
WHERE eps.hostid = ?
|
WHERE eps.hostid = ?
|
||||||
')
|
'
|
||||||
%-->
|
%-->
|
||||||
<!--% query_twt_shows = DBI.prepare('
|
<!--% query_twt_shows = '
|
||||||
SELECT
|
SELECT
|
||||||
eps.id,
|
eps.id,
|
||||||
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
CASE eps.explicit WHEN 1 THEN \'Explicit\' ELSE \'Clean\' END AS explicit ,
|
||||||
@@ -44,6 +44,6 @@
|
|||||||
INNER JOIN miniseries ON eps.series = miniseries.id
|
INNER JOIN miniseries ON eps.series = miniseries.id
|
||||||
WHERE hosts.hostid = ?
|
WHERE hosts.hostid = ?
|
||||||
ORDER BY eps.id DESC
|
ORDER BY eps.id DESC
|
||||||
')
|
'
|
||||||
%-->
|
%-->
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user