feat: Filter generic note type retrieval to their own deck

This commit is contained in:
Dendy 2025-10-05 08:42:06 +02:00
parent c7c1070f74
commit 5fa099bfe1
1 changed files with 16 additions and 5 deletions

View File

@ -77,9 +77,20 @@ class AnkiService
}
/** @return list<int> */
public function getAllIdsFromClass(string $class): array
{
$query = sprintf('"note:%s"', constant("$class::MODEL_NAME"));
public function getAllIdsFromClass(
string $class,
?bool $isSuspended = null,
): array {
$query = sprintf(
'"deck:%s" "note:%s" %s',
constant("$class::DECK"),
constant("$class::MODEL_NAME"),
match ($isSuspended) {
null => '',
true => 'is:suspended',
false => '-is:suspended',
}
);
return $this->request('findNotes', ['query' => $query]);
}
@ -88,9 +99,9 @@ class AnkiService
* @param class-string<T> $class
* @return list<T>
*/
public function getAllFromClass(string $class): array
public function getAllFromClass(string $class, ?bool $isSuspended): array
{
$ids = $this->getAllIdsFromClass($class);
$ids = $this->getAllIdsFromClass($class, $isSuspended);
return $this->getNotes($ids);
}