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