Compare commits
No commits in common. "c8278b506ade86abae508cc07a0d7d6c5ae46a90" and "c7c1070f7448d2cf2ba4bf7585acc9907f63acbf" have entirely different histories.
c8278b506a
...
c7c1070f74
|
@ -89,10 +89,30 @@ 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->ankiService->getAllFromClass(SentenceNote::class, false);
|
||||
$allListeningNotes = $this->ankiService->getAllFromClass(SentenceListeningNote::class, false);
|
||||
$allSentenceNotes = $this->getAllSentenceNotes();
|
||||
$allListeningNotes = $this->getAllSentenceListeningNotes();
|
||||
|
||||
// Index of all the Terms indexed by its TermKanji
|
||||
$allTerms = []; // ["パレートの法則" => App\Entity\Term]
|
||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Entity;
|
|||
class SentenceNote extends Note
|
||||
{
|
||||
const MODEL_NAME = 'Japanese sentences';
|
||||
const DECK = '日本語::音読';
|
||||
|
||||
private ?array $mediaInfo = [];
|
||||
private array $terms = [];
|
||||
|
|
|
@ -77,20 +77,9 @@ class AnkiService
|
|||
}
|
||||
|
||||
/** @return list<int> */
|
||||
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',
|
||||
}
|
||||
);
|
||||
public function getAllIdsFromClass(string $class): array
|
||||
{
|
||||
$query = sprintf('"note:%s"', constant("$class::MODEL_NAME"));
|
||||
return $this->request('findNotes', ['query' => $query]);
|
||||
}
|
||||
|
||||
|
@ -99,9 +88,9 @@ class AnkiService
|
|||
* @param class-string<T> $class
|
||||
* @return list<T>
|
||||
*/
|
||||
public function getAllFromClass(string $class, ?bool $isSuspended): array
|
||||
public function getAllFromClass(string $class): array
|
||||
{
|
||||
$ids = $this->getAllIdsFromClass($class, $isSuspended);
|
||||
$ids = $this->getAllIdsFromClass($class);
|
||||
return $this->getNotes($ids);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue