Caching of server-wide stats improved, fixed merging error
Had a lot of issues with the last merger and might have lost some changes. This build is functional.
|
@ -24,7 +24,7 @@ A website-based platform and API for collecting Plex user stats within a set tim
|
|||
## Instructions
|
||||
This is a web-based platform. Place it in a webserver like Apache or Nginx and make sure it processes PHP content.
|
||||
|
||||
There are multiple settings you must configure! They will be stored in config/config.json, but can be configured easily at <b>you-domain-or-ip.com/admin</b>.
|
||||
There are multiple settings you must configure! They will be stored in config/config.json, but can be configured easily at <b>you-domain-or-ip/admin.html</b>.
|
||||
|
||||
PHP will have issues with this API based on the results you want. If you have a large time frame for your wrapped period and there is a huge amount of Tautulli entries you can have multiple issues.
|
||||
In your php.ini file you may have to change:
|
||||
|
@ -32,11 +32,11 @@ In your php.ini file you may have to change:
|
|||
- memory_limit=<b>enough M for the script to handle JSON data</b>
|
||||
- max_input_time=<b>enough seconds for the script to parse JSON data</b>
|
||||
|
||||
You need to give PHP permission to edit files in the directory called <b>config</b>
|
||||
You need to give PHP permission to edit files in the directory called <b>config</b>.
|
||||
|
||||
The cache is stored at config/cache.json, but can be cleared using the admin menu.
|
||||
|
||||
If you visit <b>you-domain-or-ip.com/caching</b> you can do a pre-caching of a set of users. This is very useful if you want to prepare for a lot of traffic.
|
||||
If you visit <b>you-domain-or-ip/caching.html</b> you can do a pre-caching of a set of users. This is very useful if you want to prepare for a lot of traffic.
|
||||
|
||||
## Need help?
|
||||
If you have any issues feel free to contact me. I am always trying to improve the project. If I can't, many people on several forums (including /r/plex) might be able to assist you.
|
||||
|
|
|
@ -45,7 +45,7 @@ if($config->use_cache) {
|
|||
$then = new DateTime($cache->date);
|
||||
$diff = $now->diff($then);
|
||||
|
||||
if($diff->format('%D') < $config->cache_age_limit) {
|
||||
if($diff->format('%a') < $config->cache_age_limit) {
|
||||
echo json_encode($cache);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -79,9 +79,9 @@ if($config->get_user_show_buddy && $config->get_user_show_stats && !empty($user_
|
|||
|
||||
if($config->get_year_stats) {
|
||||
if($config->use_cache) {
|
||||
$year_stats = array("data" => tautulli_get_year_stats_cache($id), "error" => False, "Message" => "Year stats are loaded.");
|
||||
$year_stats = array("data" => tautulli_get_year_stats_cache($id), "error" => False, "message" => "Year stats are loaded.");
|
||||
} else {
|
||||
$year_stats = array("data" => tautulli_get_year_stats($id), "error" => False, "Message" => "Year stats are loaded.");
|
||||
$year_stats = array("data" => tautulli_get_year_stats($id), "error" => False, "message" => "Year stats are loaded.");
|
||||
}
|
||||
} else {
|
||||
$year_stats = array("data" => array(), "message" => "Disabled in config.", "error" => True);
|
||||
|
@ -450,10 +450,10 @@ function tautulli_get_year_stats_cache($id) {
|
|||
if(!empty($cache)) {
|
||||
for($i = 0; $i < count($cache); $i++) {
|
||||
$now = new DateTime('NOW');
|
||||
$then = new DateTime($cache[$i]->date);
|
||||
$diff = $now->diff($then);
|
||||
$then = new DateTime($cache[$i]->year_stats->data->origin_date);
|
||||
$diff = $then->diff($now);
|
||||
|
||||
if($diff->format('%D') < $config->cache_age_limit) {
|
||||
if($diff->format('%a') < $config->cache_age_limit && !$cache[$i]->year_stats->error) {
|
||||
return $cache[$i]->year_stats->data;
|
||||
}
|
||||
}
|
||||
|
@ -592,6 +592,8 @@ function tautulli_get_year_stats($id) {
|
|||
$duration = array_column($users, 'duration');
|
||||
array_multisort($duration, SORT_DESC, $users);
|
||||
|
||||
return array("top_movies" => $movies, "users" => $users, "top_shows" => $shows);
|
||||
$now = new DateTime('NOW');
|
||||
|
||||
return array("origin_date" => $now->format('Y-m-d'), "top_movies" => $movies, "users" => $users, "top_shows" => $shows);
|
||||
}
|
||||
?>
|
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 166 KiB |
BIN
assets/img/example_01.PNG
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
assets/img/example_02.PNG
Normal file
After Width: | Height: | Size: 114 KiB |
BIN
assets/img/example_03.PNG
Normal file
After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 128 KiB |
|
@ -65,7 +65,7 @@
|
|||
|
||||
</div>
|
||||
|
||||
<img id="loading_icon" src="assets/loading.gif" style="padding: 1em;width: 2em; height: 2em; display:none;">
|
||||
<img id="loading_icon" src="assets/loading.gif" style="border-radius: 25px; background-color: white; padding: 1em;width: 4em; height: 4em; display:none;">
|
||||
|
||||
<div id="results">
|
||||
|
||||
|
|