diff --git a/cms/stats.php b/cms/stats.php index 02e06f7..d5088d5 100644 --- a/cms/stats.php +++ b/cms/stats.php @@ -18,11 +18,12 @@ if (isset($_GET['format'])){ } } -$twat_startdate = abs(strtotime(date("c")) - strtotime("2005-09-19T00:00:00Z")); -$twat_years = floor($twat_startdate / (365*60*60*24)); -$twat_months = floor(($twat_startdate - $twat_years * 365*60*60*24) / (30*60*60*24)); -$twat_days = floor(($twat_startdate - $twat_years * 365*60*60*24 - $twat_months*30*60*60*24)/ (60*60*24)); -$agetwat = $twat_startdate; +$total_twt_shows = 300; +$twt_startdate = abs(strtotime(date("c")) - strtotime("2005-09-19T00:00:00Z")); +$twt_years = floor($twt_startdate / (365*60*60*24)); +$twt_months = floor(($twt_startdate - $twt_years * 365*60*60*24) / (30*60*60*24)); +$twt_days = floor(($twt_startdate - $twt_years * 365*60*60*24 - $twt_months*30*60*60*24)/ (60*60*24)); +$agetwt = $twt_startdate; $hpr_startdate = abs(strtotime(date("c")) - strtotime("2007-12-31T00:00:00Z")); $hpr_years = floor($hpr_startdate / (365*60*60*24)); @@ -53,7 +54,7 @@ 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 @@ -158,10 +159,10 @@ $num_submitted_shows = $data['total']; // -------------------------------------------- // Duration of all shows -$result=mysqli_query($connection, "SELECT SUM(duration) as total_duration FROM `eps`"); +$result=mysqli_query($connection, "SELECT SUM(duration) as total_playtime FROM `eps`"); $data=mysqli_fetch_assoc($result); -$total_duration = $data['total_duration']; -$human_total_duration = convertSecToTime($total_duration); +$total_playtime = $data['total_playtime']; +$human_total_playtime = convertSecToTime($total_playtime); // -------------------------------------------- // workflow @@ -182,11 +183,11 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { },"; // -------------------------------------------- -// duration -$result=mysqli_query($connection, "SELECT SUM(duration) as total_duration FROM `eps`"); +// playtime +$result=mysqli_query($connection, "SELECT SUM(duration) as total_playtime FROM `eps`"); $data=mysqli_fetch_assoc($result); -$total_duration = $data['total_duration']; -$human_total_duration = convertSecToTime($total_duration); +$total_playtime = $data['total_playtime']; +$human_total_playtime = convertSecToTime($total_playtime); // -------------------------------------------- // Unprocessed comments @@ -206,6 +207,13 @@ if ($handle = opendir('/home/hpr/upload')) { closedir($handle); } +// -------------------------------------------- +// Calculate Total Shows + + +$total_shows = $current_episode_number + $total_twt_shows + $num_future_shows + $reserve_shows; + + // -------------------------------------------- // Produce output @@ -220,10 +228,10 @@ if ($format === "json") { \"start\": \"2005-09-19T00:00:00Z\", \"rename\": \"2007-12-31T00:00:00Z\", \"since_start\": { - \"total_seconds\": ".$agetwat.", - \"years\": ".$twat_years.", - \"months\": ".$twat_months.", - \"days\": ".$twat_days." + \"total_seconds\": ".$agetwt.", + \"years\": ".$twt_years.", + \"months\": ".$twt_months.", + \"days\": ".$twt_days." }, \"since_rename\": { \"total_seconds\": ".$agehpr.", @@ -234,10 +242,12 @@ if ($format === "json") { }, \"shows\": { \"total\": ".$total_shows.", - \"twat\": 300, - \"hpr\": ".$total_hpr_shows.", - \"duration\": ".$total_duration.", - \"human_duration\": \"".$human_total_duration."\" + \"twt\": $total_twt_shows, + \"hpr\": ".$current_episode_number.", + \"future\": ".$num_future_shows.", + \"reserve\": ".$reserve_shows.", + \"playtime\": ".$total_playtime.", + \"human_playtime\": \"".$human_total_playtime."\" }, \"hosts\": ".$num_of_hosts.", \"slot\": { @@ -266,10 +276,10 @@ elseif ($format === "xml") { 2005-09-19T00:00:00Z 2007-12-31T00:00:00Z - ".$agetwat." - ". $twat_years." - ".$twat_months." - ".$twat_days." + ".$agetwt." + ". $twt_years." + ".$twt_months." + ".$twt_days." ".$agehpr." @@ -280,10 +290,10 @@ elseif ($format === "xml") { ".$total_shows." - 300 + $total_twt_shows ".$total_hpr_shows." - ".$total_duration." - ".$human_total_duration." + ".$total_playtime." + ".$human_total_playtime." ".$num_of_hosts." @@ -304,20 +314,20 @@ elseif ($format === "csv") { header("Content-type: text/csv"); header("Content-disposition: inline; filename=hpr_stats.csv"); - print "stats_generated,age_start,age_rename,age_since_start_total_seconds,age_since_start_years,age_since_start_months,age_since_start_days,age_since_rename_total_seconds,age_since_rename_years,age_since_rename_months,age_since_rename_days,shows_total,shows_twat,shows_hpr,hosts,slot_next_free,slot_no_media,number_future_hosts,number_future_shows,unprocessed_comments,shows_in_workflow,queue_reserve,duration\n"; - print "${current_time},2005-09-19T00:00:00Z,2007-12-31T00:00:00Z,${agetwat},${twat_years},${twat_months},${twat_days},${agehpr},${hpr_years},${hpr_months},${hpr_days},${totalshows},300,${totalhpr},${num_of_hosts},${days_to_wait},${un_delivered},${num_future_hosts},${num_future_shows},${unprocessed_comments},${new_shows},${reserve_shows},${total_duration}\n"; + print "stats_generated,age_start,age_rename,age_since_start_total_seconds,age_since_start_years,age_since_start_months,age_since_start_days,age_since_rename_total_seconds,age_since_rename_years,age_since_rename_months,age_since_rename_days,shows_total,shows_twt,shows_hpr,hosts,slot_next_free,slot_no_media,number_future_hosts,number_future_shows,unprocessed_comments,shows_in_workflow,queue_reserve,playtime\n"; + print "${current_time},2005-09-19T00:00:00Z,2007-12-31T00:00:00Z,${agetwt},${twt_years},${twt_months},${twt_days},${agehpr},${hpr_years},${hpr_months},${hpr_days},${totalshows},$total_twt_shows,${totalhpr},${num_of_hosts},${days_to_wait},${un_delivered},${num_future_hosts},${num_future_shows},${unprocessed_comments},${new_shows},${reserve_shows},${total_playtime}\n"; } else { Header('Content-type: text/tab-separated-values'); 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("Started:\t%d years, %d months, %d days ago (2005-09-19)\n", $twt_years, $twt_months, $twt_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" . $total_shows . "\n"; - echo "Total TWAT:\t300\n"; + echo "Total TWAT:\t$total_twt_shows\n"; echo "Total HPR:\t" . $total_hpr_shows . "\n"; - echo "Duration:\t" . $total_duration . "\n"; - echo "Human Duration:\t" . $human_total_duration . "\n"; + echo "Duration:\t" . $total_playtime . "\n"; + echo "Human Duration:\t" . $human_total_playtime . "\n"; echo "HPR Hosts:\t${num_of_hosts}\n"; echo "Days to next free slot:\t${days_to_wait}\n"; echo "Hosts in Queue:\t$num_future_hosts\n"; @@ -326,7 +336,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,$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 "$current_time,$agetwt,$agehpr,$total_shows,$total_twt_shows,$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);