Fix stats page hpr shows with playtime

This commit is contained in:
Ken Fallon 2024-10-10 11:02:03 +02:00
parent 112f443a04
commit 8bf6aad70b

View File

@ -18,11 +18,12 @@ if (isset($_GET['format'])){
} }
} }
$twat_startdate = abs(strtotime(date("c")) - strtotime("2005-09-19T00:00:00Z")); $total_twt_shows = 300;
$twat_years = floor($twat_startdate / (365*60*60*24)); $twt_startdate = abs(strtotime(date("c")) - strtotime("2005-09-19T00:00:00Z"));
$twat_months = floor(($twat_startdate - $twat_years * 365*60*60*24) / (30*60*60*24)); $twt_years = floor($twt_startdate / (365*60*60*24));
$twat_days = floor(($twat_startdate - $twat_years * 365*60*60*24 - $twat_months*30*60*60*24)/ (60*60*24)); $twt_months = floor(($twt_startdate - $twt_years * 365*60*60*24) / (30*60*60*24));
$agetwat = $twat_startdate; $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_startdate = abs(strtotime(date("c")) - strtotime("2007-12-31T00:00:00Z"));
$hpr_years = floor($hpr_startdate / (365*60*60*24)); $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); $data=mysqli_fetch_assoc($result);
$total_hpr_shows = $data['total_hpr_shows']; $total_hpr_shows = $data['total_hpr_shows'];
} }
$total_shows=$last_show_date[1]+300+$reserve_shows;
// -------------------------------------------- // --------------------------------------------
// Get the number of hosts // Get the number of hosts
@ -158,10 +159,10 @@ $num_submitted_shows = $data['total'];
// -------------------------------------------- // --------------------------------------------
// Duration of all shows // 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); $data=mysqli_fetch_assoc($result);
$total_duration = $data['total_duration']; $total_playtime = $data['total_playtime'];
$human_total_duration = convertSecToTime($total_duration); $human_total_playtime = convertSecToTime($total_playtime);
// -------------------------------------------- // --------------------------------------------
// workflow // workflow
@ -182,11 +183,11 @@ if ($result = mysqli_query($connection, $ep_retrieve)) {
},"; },";
// -------------------------------------------- // --------------------------------------------
// duration // playtime
$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); $data=mysqli_fetch_assoc($result);
$total_duration = $data['total_duration']; $total_playtime = $data['total_playtime'];
$human_total_duration = convertSecToTime($total_duration); $human_total_playtime = convertSecToTime($total_playtime);
// -------------------------------------------- // --------------------------------------------
// Unprocessed comments // Unprocessed comments
@ -206,6 +207,13 @@ if ($handle = opendir('/home/hpr/upload')) {
closedir($handle); closedir($handle);
} }
// --------------------------------------------
// Calculate Total Shows
$total_shows = $current_episode_number + $total_twt_shows + $num_future_shows + $reserve_shows;
// -------------------------------------------- // --------------------------------------------
// Produce output // Produce output
@ -220,10 +228,10 @@ if ($format === "json") {
\"start\": \"2005-09-19T00:00:00Z\", \"start\": \"2005-09-19T00:00:00Z\",
\"rename\": \"2007-12-31T00:00:00Z\", \"rename\": \"2007-12-31T00:00:00Z\",
\"since_start\": { \"since_start\": {
\"total_seconds\": ".$agetwat.", \"total_seconds\": ".$agetwt.",
\"years\": ".$twat_years.", \"years\": ".$twt_years.",
\"months\": ".$twat_months.", \"months\": ".$twt_months.",
\"days\": ".$twat_days." \"days\": ".$twt_days."
}, },
\"since_rename\": { \"since_rename\": {
\"total_seconds\": ".$agehpr.", \"total_seconds\": ".$agehpr.",
@ -234,10 +242,12 @@ if ($format === "json") {
}, },
\"shows\": { \"shows\": {
\"total\": ".$total_shows.", \"total\": ".$total_shows.",
\"twat\": 300, \"twt\": $total_twt_shows,
\"hpr\": ".$total_hpr_shows.", \"hpr\": ".$current_episode_number.",
\"duration\": ".$total_duration.", \"future\": ".$num_future_shows.",
\"human_duration\": \"".$human_total_duration."\" \"reserve\": ".$reserve_shows.",
\"playtime\": ".$total_playtime.",
\"human_playtime\": \"".$human_total_playtime."\"
}, },
\"hosts\": ".$num_of_hosts.", \"hosts\": ".$num_of_hosts.",
\"slot\": { \"slot\": {
@ -266,10 +276,10 @@ elseif ($format === "xml") {
<start>2005-09-19T00:00:00Z</start> <start>2005-09-19T00:00:00Z</start>
<rename>2007-12-31T00:00:00Z</rename> <rename>2007-12-31T00:00:00Z</rename>
<since_start> <since_start>
<total_seconds>".$agetwat."</total_seconds> <total_seconds>".$agetwt."</total_seconds>
<years>". $twat_years."</years> <years>". $twt_years."</years>
<months>".$twat_months."</months> <months>".$twt_months."</months>
<days>".$twat_days."</days> <days>".$twt_days."</days>
</since_start> </since_start>
<since_rename> <since_rename>
<total_seconds>".$agehpr."</total_seconds> <total_seconds>".$agehpr."</total_seconds>
@ -280,10 +290,10 @@ elseif ($format === "xml") {
</age> </age>
<shows> <shows>
<total>".$total_shows."</total> <total>".$total_shows."</total>
<twat>300</twat> <twt>$total_twt_shows</twt>
<hpr>".$total_hpr_shows."</hpr> <hpr>".$total_hpr_shows."</hpr>
<duration>".$total_duration."</duration> <playtime>".$total_playtime."</playtime>
<human_duration>".$human_total_duration."</human_duration> <human_playtime>".$human_total_playtime."</human_playtime>
</shows> </shows>
<hosts>".$num_of_hosts."</hosts> <hosts>".$num_of_hosts."</hosts>
<slot> <slot>
@ -304,20 +314,20 @@ elseif ($format === "csv") {
header("Content-type: text/csv"); header("Content-type: text/csv");
header("Content-disposition: inline; filename=hpr_stats.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 "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,${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 "${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 { else {
Header('Content-type: text/tab-separated-values'); Header('Content-type: text/tab-separated-values');
header("Content-disposition: inline; filename=hpr_stats.txt"); 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); 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 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 "Total HPR:\t" . $total_hpr_shows . "\n";
echo "Duration:\t" . $total_duration . "\n"; echo "Duration:\t" . $total_playtime . "\n";
echo "Human Duration:\t" . $human_total_duration . "\n"; echo "Human Duration:\t" . $human_total_playtime . "\n";
echo "HPR Hosts:\t${num_of_hosts}\n"; echo "HPR Hosts:\t${num_of_hosts}\n";
echo "Days to next free slot:\t${days_to_wait}\n"; echo "Days to next free slot:\t${days_to_wait}\n";
echo "Hosts in Queue:\t$num_future_hosts\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 "Files on the FTP Server:\t$new_shows\n";
echo "Number of Reserve Shows:\t$reserve_shows\n"; echo "Number of Reserve Shows:\t$reserve_shows\n";
echo "Days until show without media:\t$un_delivered\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); // print_r($show_array);
} }
mysqli_close($connection); mysqli_close($connection);