diff --git a/cms/add_show_json.php b/cms/add_show_json.php index aae6642..dc480cf 100644 --- a/cms/add_show_json.php +++ b/cms/add_show_json.php @@ -116,10 +116,10 @@ else { $provided_notes = urldecode( $decoded_json["notes"] ); -if ( empty($provided_notes) or strlen($provided_notes) > 100000 ) { - problem("Notes are missing not less than max"); +if ( empty($provided_notes) ) { + problem("Notes are missing "); } -logextra( "Notes are present and are under the max length" ); +logextra( "Notes are present " ); $notes = $provided_notes; @@ -531,9 +531,7 @@ if ( strcmp( $host_license, $db_license ) !== 0 ) { logextra( "Updating the host license" ); } } -else { - logextra( "The host_license is the same to that in the db \"$host_license\"" ); -} +logextra( "The host_license is the same to that in the db \"$host_license\"" ); $title = mysqli_real_escape_string( $connection, $title ); $summary = mysqli_real_escape_string( $connection, $summary ); @@ -541,10 +539,15 @@ $notes = mysqli_real_escape_string( $connection, $notes ); $tags = mysqli_real_escape_string( $connection, $tags ); $query_add = "INSERT INTO eps VALUES ('$ep_num', '{$ep_date}', '{$title}', '{$duration}', '{$summary}', '{$notes}', '{$host_id}', '{$series_id}', '{$explicit}', '{$episode_license}', '{$tags}', '0', '0', '0')"; + +logextra( "About to add to db" ); + $result = mysqli_query($connection, $query_add ); if(!$result) { problem("DB problem - The show $ep_num was not added to the eps db."); } +logextra( "Response from db \"$result\"" ); + if (mysqli_errno( $connection )) { $error = "MySQL error ".mysqli_errno( $connection ).": ".mysqli_error()."\n"; problem("MySQL error- The show $ep_num was not added to the eps db.\n$error"); diff --git a/cms/stats.php b/cms/stats.php index 2b8f761..06863c7 100644 --- a/cms/stats.php +++ b/cms/stats.php @@ -51,6 +51,35 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { $next_free_slot = "https://repo.anhonesthost.net/HPR/hpr_hub/issues/71"; +// -------------------------------------------- +// Get the Shortest Show + +$ep_retrieve = "SELECT id, duration FROM eps WHERE duration = ( SELECT MIN(duration) FROM eps WHERE duration > 0 AND id != 903)"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + $data=mysqli_fetch_assoc($result); + $min_duration_seconds = intval( $data['duration'] ); + $min_duration_episode_number = intval( $data['id'] ); +} + +// -------------------------------------------- +// Get the Longest Show + +$ep_retrieve = "SELECT id, duration FROM eps WHERE duration = ( SELECT MAX(duration) FROM eps WHERE duration > 0 AND id != 903)"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + $data=mysqli_fetch_assoc($result); + $max_duration_seconds = intval( $data['duration'] ); + $max_duration_episode_number = intval( $data['id'] ); +} + +// -------------------------------------------- +// Get the Average Show + +$ep_retrieve = "SELECT AVG(duration) as avg_duration FROM `eps` WHERE duration > 0"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + $data=mysqli_fetch_assoc($result); + $avg_duration_seconds = intval( $data['avg_duration'] ); +} + // -------------------------------------------- // playtime $ep_retrieve = "SELECT SUM(duration) as total_playtime_all_hpr_shows_seconds FROM `eps`"; @@ -74,7 +103,10 @@ $total_released_shows = $latest_episode_id + $total_twt_shows; $total_submitted_shows = $latest_episode_id + $total_twt_shows + $num_future_shows + $num_reserve_shows; $project_age_seconds = strtotime( $start_date_twt ) - $current_time; -$project_age = convertSecToTime( $project_age_seconds ); +$project_age = convertSecToTime( $project_age_seconds ); +$min_duration = convertSecToTime( $min_duration_seconds ); +$max_duration = convertSecToTime( $max_duration_seconds ); +$avg_duration = convertSecToTime( $avg_duration_seconds ); // -------------------------------------------- @@ -114,6 +146,14 @@ $arr = array( 'num_reserve_shows' => $num_reserve_shows, 'total_submitted_shows' => $total_submitted_shows, 'num_hosts' => $num_hosts, + 'shortest_show_number' => $min_duration_episode_number, + 'shortest_show_duration' => $min_duration, + 'shortest_show_seconds' => $min_duration_seconds, + 'longest_show_number' => $max_duration_episode_number, + 'longest_show_duration' => $max_duration, + 'longest_show_seconds' => $max_duration_seconds, + 'average_show_length' => $avg_duration, + 'average_show_length_seconds' => $avg_duration_seconds, 'days_to_next_free_slot' => "todo", 'total_playtime_all_shows_seconds' => $total_playtime_all_shows_seconds, 'total_playtime_all_shows_human_readable' => $total_playtime_all_shows_human_readable,