Warning when library ID's are not set & Fixed cache age bug

If you gather stats without providing ID for said library you are now warned in the admin config.
Fixed a bug where the "optional" cache age-limit would not work if 0 or empty.
This commit is contained in:
aunefyren 2021-10-04 14:57:28 +02:00
parent 77aae5925c
commit 3381249172
3 changed files with 37 additions and 2 deletions

View file

@ -252,7 +252,12 @@ function set_tautulli_details(back) {
html += '<input type="datetime-local" class="form-control" id="wrapped_end" value="' + temp_date_first[2].trim() + '-' + temp_date_first[1].trim() + '-' + temp_date_first[0].trim() + 'T' + temp_date_second[0].trim() + ':' + temp_date_second[1].trim() + '" required /></label>';
html += '</div>';
html += '<hr>';
html += '<div class="form-group">';
if(library_id_movies == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for movie library not configured!</div>';
}
html += '<label for="get_user_movie_stats" title="Includes movie statistics in your wrapped period.">Get users movie statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_user_movie_stats" ';
if(get_user_movie_stats) {
@ -262,6 +267,9 @@ function set_tautulli_details(back) {
html += '</div>';
html += '<div class="form-group">';
if(library_id_shows == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for show library not configured!</div>';
}
html += '<label for="get_user_show_stats" title="Includes show statistics in your wrapped period.">Get users show statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_user_show_stats" ';
if(get_user_show_stats) {
@ -271,6 +279,9 @@ function set_tautulli_details(back) {
html += '</div>';
html += '<div class="form-group">';
if(library_id_shows == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for show library not configured!</div>';
}
html += '<label for="get_user_show_buddy" title="Includes the users top show-buddy in your wrapped period. Requires show stats.">Get users show-buddy<br>';
html += '<input type="checkbox" class="form-control" id="get_user_show_buddy" ';
if(get_user_show_buddy) {
@ -280,6 +291,9 @@ function set_tautulli_details(back) {
html += '</div>';
html += '<div class="form-group">';
if(library_id_music == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for music library not configured!</div>';
}
html += '<label for="get_user_music_stats" title="Includes music statistics in your wrapped period.">Get users music statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_user_music_stats" ';
if(get_user_music_stats) {
@ -288,7 +302,12 @@ function set_tautulli_details(back) {
html += '/><br>';
html += '</div>';
html += '<hr>';
html += '<div class="form-group">';
if(library_id_movies == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for movie library not configured!</div>';
}
html += '<label for="get_year_stats_movies" title="Includes server-wide movie statistics in your wrapped period.">Get server-wide movie statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_year_stats_movies" ';
if(get_year_stats_movies) {
@ -298,6 +317,9 @@ function set_tautulli_details(back) {
html += '</div>';
html += '<div class="form-group">';
if(library_id_shows == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for show library not configured!</div>';
}
html += '<label for="get_year_stats_shows" title="Includes server-wide show statistics in your wrapped period.">Get server-wide show statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_year_stats_shows" ';
if(get_year_stats_shows) {
@ -307,6 +329,9 @@ function set_tautulli_details(back) {
html += '</div>';
html += '<div class="form-group">';
if(library_id_music == "") {
html += '<div class="warning" title="ID needed to find data.">Warning!<br>ID for music library not configured!</div>';
}
html += '<label for="get_year_stats_music" title="Includes server-wide music statistics in your wrapped period.">Get server-wide music statistics<br>';
html += '<input type="checkbox" class="form-control" id="get_year_stats_music" ';
if(get_year_stats_music) {
@ -323,6 +348,8 @@ function set_tautulli_details(back) {
}
html += '/><br>';
html += '</div>';
html += '<hr>';
html += '<div class="form-group">';
html += '<label for="use_logs" title="Logs every API request into a log-file in the config folder. ID for Wrapped request included.">Log API calls<br>';

View file

@ -59,7 +59,7 @@ if($config->use_cache) {
$then = new DateTime($cache->date);
$diff = $now->diff($then);
if($diff->format('%a') < $config->cache_age_limit) {
if($diff->format('%a') < $config->cache_age_limit || $config->cache_age_limit == "" || $config->cache_age_limit == 0) {
echo json_encode($cache);
exit(0);
}
@ -549,7 +549,7 @@ function tautulli_get_year_stats_cache($id) {
$then = new DateTime($cache[$i]->year_stats->data->origin_date);
$diff = $then->diff($now);
if($diff->format('%a') < $config->cache_age_limit && !$cache[$i]->year_stats->error) {
if(($diff->format('%a') < $config->cache_age_limit || $config->cache_age_limit == "" || $config->cache_age_limit == 0) && !$cache[$i]->year_stats->error) {
return $cache[$i]->year_stats->data;
}
}

View file

@ -154,6 +154,14 @@ img {
width: 22em;
}
.warning {
padding: 0.5em;
margin: 0.5em;
background-color: #ffbd55;
border-radius: 25px;
color: black;
}
.boks-knapp {
height: 5em;
width: 100% !important;