refactor(integration) : drop unused bookstack shelf-id cache
This commit is contained in:
@@ -15,9 +15,6 @@ use Throwable;
|
||||
|
||||
final class BookStackApiService
|
||||
{
|
||||
/** @var array<int, int[]> */
|
||||
private array $shelfBookCache = [];
|
||||
|
||||
public function __construct(
|
||||
private readonly HttpClientInterface $httpClient,
|
||||
private readonly BookStackConfigurationRepositoryInterface $configRepository,
|
||||
@@ -81,9 +78,6 @@ final class BookStackApiService
|
||||
$bookSlugs[$book['id']] = $book['slug'] ?? '';
|
||||
}
|
||||
|
||||
// Update cache for getShelfBookIds
|
||||
$this->shelfBookCache[$shelfId] = $bookIds;
|
||||
|
||||
$config = $this->getConfiguration();
|
||||
$baseUrl = rtrim($config->getUrl() ?? '', '/');
|
||||
$trimmed = trim($query);
|
||||
@@ -141,24 +135,6 @@ final class BookStackApiService
|
||||
return $this->request('GET', sprintf('/api/books/%d', $id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
private function getShelfBookIds(int $shelfId): array
|
||||
{
|
||||
if (isset($this->shelfBookCache[$shelfId])) {
|
||||
return $this->shelfBookCache[$shelfId];
|
||||
}
|
||||
|
||||
$data = $this->request('GET', sprintf('/api/shelves/%d', $shelfId));
|
||||
$books = $data['books'] ?? [];
|
||||
|
||||
$ids = array_map(static fn (array $book): int => $book['id'], $books);
|
||||
$this->shelfBookCache[$shelfId] = $ids;
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
private function getConfiguration(): BookStackConfiguration
|
||||
{
|
||||
$config = $this->configRepository->findSingleton();
|
||||
|
||||
Reference in New Issue
Block a user