From 112f443a04e8e15d4c2fe231d8f2a2f95c154540 Mon Sep 17 00:00:00 2001 From: Ken Fallon Date: Thu, 10 Oct 2024 10:48:23 +0200 Subject: [PATCH] Fix stats page hpr shows --- cms/stats.php | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/cms/stats.php b/cms/stats.php index 725346b..02e06f7 100644 --- a/cms/stats.php +++ b/cms/stats.php @@ -33,8 +33,27 @@ $agehpr = $hpr_startdate; $last_show = mysqli_query($connection, "SELECT max(date), max(id) from eps"); $last_show_date = mysqli_fetch_row($last_show); -$totalshows=$last_show_date[1]+300; -$totalhpr=$last_show_date[1]; + +// -------------------------------------------- +// Reserve Shows + +$result = mysqli_query($connection, 'SELECT COUNT(*) FROM reservations WHERE status="RESERVE_SHOW_SUBMITTED";'); +if (!isset($result)) { + naughty("cac33babd8a24edd138087ef7e4280f6"); +} +$reserve_array = mysqli_fetch_row( $result ); +$reserve_shows = $reserve_array[0]; +mysqli_free_result($result); + +// -------------------------------------------- +// Get total number of shows + +$ep_retrieve = "SELECT id, COUNT(*) AS total_hpr_shows FROM eps ;"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + $data=mysqli_fetch_assoc($result); + $total_hpr_shows = $data['total_hpr_shows']; +} +$total_shows=$last_show_date[1]+300+$reserve_shows; // -------------------------------------------- // Get the number of hosts @@ -144,17 +163,6 @@ $data=mysqli_fetch_assoc($result); $total_duration = $data['total_duration']; $human_total_duration = convertSecToTime($total_duration); -// -------------------------------------------- -// Reserve Shows - -$result = mysqli_query($connection, 'SELECT COUNT(*) FROM reservations WHERE status="RESERVE_SHOW_SUBMITTED";'); -if (!isset($result)) { - naughty("cac33babd8a24edd138087ef7e4280f6"); -} -$reserve_array = mysqli_fetch_row( $result ); -$reserve_shows = $reserve_array[0]; -mysqli_free_result($result); - // -------------------------------------------- // workflow @@ -225,9 +233,9 @@ if ($format === "json") { } }, \"shows\": { - \"total\": ".$totalshows.", + \"total\": ".$total_shows.", \"twat\": 300, - \"hpr\": ".$totalhpr.", + \"hpr\": ".$total_hpr_shows.", \"duration\": ".$total_duration.", \"human_duration\": \"".$human_total_duration."\" }, @@ -271,9 +279,9 @@ elseif ($format === "xml") { - ".$totalshows." + ".$total_shows." 300 - ".$totalhpr." + ".$total_hpr_shows." ".$total_duration." ".$human_total_duration." @@ -305,9 +313,9 @@ else { header("Content-disposition: inline; filename=hpr_stats.txt"); printf("Started:\t%d years, %d months, %d days ago (2005-09-19)\n", $twat_years, $twat_months, $twat_days); printf("Renamed HPR:\t%d years, %d months, %d days ago (2007-12-31)\n", $hpr_years, $hpr_months, $hpr_days); - echo "Total Shows:\t" . $totalshows . "\n"; + echo "Total Shows:\t" . $total_shows . "\n"; echo "Total TWAT:\t300\n"; - echo "Total HPR:\t" . $totalhpr . "\n"; + echo "Total HPR:\t" . $total_hpr_shows . "\n"; echo "Duration:\t" . $total_duration . "\n"; echo "Human Duration:\t" . $human_total_duration . "\n"; echo "HPR Hosts:\t${num_of_hosts}\n"; @@ -318,7 +326,7 @@ else { echo "Files on the FTP Server:\t$new_shows\n"; echo "Number of Reserve Shows:\t$reserve_shows\n"; echo "Days until show without media:\t$un_delivered\n"; - print "$current_time,$agetwat,$agehpr,$totalshows,300,$totalhpr,$num_of_hosts,$days_to_wait,$num_future_hosts,$num_future_shows,$unprocessed_comments,$new_shows,$reserve_shows,$un_delivered"; + print "$current_time,$agetwat,$agehpr,$total_shows,300,$total_hpr_shows,$num_of_hosts,$days_to_wait,$num_future_hosts,$num_future_shows,$unprocessed_comments,$new_shows,$reserve_shows,$un_delivered"; // print_r($show_array); } mysqli_close($connection);