Compare commits

...

2 Commits

3 changed files with 19 additions and 27 deletions

View File

@ -89,30 +89,10 @@ class CreateProductionCommand extends Command
}
}
/** @return list<SentenceNote> */
private function getAllSentenceNotes(): array
{
printf('Getting all SentenceNote...');
$allIds = $this->ankiService->getAllSentenceNoteIds();
$allNotes = $this->ankiService->getNotes($allIds);
printf(" OK (%d)\n", count($allNotes));
return $allNotes;
}
/** @return list<SentenceListeningNote> */
private function getAllSentenceListeningNotes(): array
{
printf('Getting all SentenceListeningNote...');
$allListeningIds = $this->ankiService->getAllSentenceListeningNoteIds();
$allListeningNotes = $this->ankiService->getNotes($allListeningIds);
printf(" OK (%d)\n", count($allListeningNotes));
return $allListeningNotes;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$allSentenceNotes = $this->getAllSentenceNotes();
$allListeningNotes = $this->getAllSentenceListeningNotes();
$allSentenceNotes = $this->ankiService->getAllFromClass(SentenceNote::class, false);
$allListeningNotes = $this->ankiService->getAllFromClass(SentenceListeningNote::class, false);
// Index of all the Terms indexed by its TermKanji
$allTerms = []; // ["パレートの法則" => App\Entity\Term]

View File

@ -5,6 +5,7 @@ namespace App\Entity;
class SentenceNote extends Note
{
const MODEL_NAME = 'Japanese sentences';
const DECK = '日本語::音読';
private ?array $mediaInfo = [];
private array $terms = [];

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);
}