feat(*): refactor dynamic vs. static structure and distinctions; make additional elements dynamic
This commit is contained in:
parent
7a0b808f24
commit
b1309908e5
126 changed files with 983 additions and 955 deletions
36
api/Classes/RecentMediaHandler.php
Normal file
36
api/Classes/RecentMediaHandler.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Classes;
|
||||
|
||||
class RecentMediaHandler extends BaseHandler
|
||||
{
|
||||
protected int $cacheTTL = 300;
|
||||
|
||||
public function getRecentMedia(): array
|
||||
{
|
||||
try {
|
||||
$cacheKey = 'recent_media';
|
||||
|
||||
if ($this->cache) {
|
||||
$cached = $this->cache->get($cacheKey);
|
||||
|
||||
if ($cached) return json_decode($cached, true);
|
||||
}
|
||||
|
||||
$response = $this->makeRequest("GET", "optimized_recent_media?select=*");
|
||||
$activity = $response[0]['recent_activity'] ?? [];
|
||||
$data = [
|
||||
'recentMusic' => $activity['recentMusic'] ?? [],
|
||||
'recentWatchedRead' => $activity['recentWatchedRead'] ?? [],
|
||||
];
|
||||
|
||||
if ($this->cache) $this->cache->set($cacheKey, json_encode($data), $this->cacheTTL);
|
||||
|
||||
return $data;
|
||||
} catch (\Exception $e) {
|
||||
error_log("RecentMediaHandler error: " . $e->getMessage());
|
||||
|
||||
return ['recentMusic' => [], 'recentWatchedRead' => []];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue