diff --git a/src/Command/CreateProductionCommand.php b/src/Command/CreateProductionCommand.php index 2c8cc4f..f5238a8 100644 --- a/src/Command/CreateProductionCommand.php +++ b/src/Command/CreateProductionCommand.php @@ -180,8 +180,11 @@ class CreateProductionCommand extends Command } printf(" OK\n"); - asort($termCounts); + $theChosenTerm = null; + arsort($termCounts); + printf("\n"); foreach ($termCounts as $term => $count) { + $theChosenTerm = $knownTerms[$term]; $termKanji = self::getOnlyKanji($term); printf("%s: %d\n", $term, $count); @@ -192,15 +195,33 @@ class CreateProductionCommand extends Command } printf("\n"); - } + break; + }; - dump(count($termCounts)); + $noteIds = $this->ankiService->findNotesIds(sprintf( + //'VocabKanji:*%s* "note:%s"', + '*%s* "note:%s"', + $theChosenTerm->getKanji(), + SentenceNote::MODEL_NAME, + )); + $theChosenNote = $this->ankiService->getNote($noteIds[array_key_last($noteIds)]); + + $fields = $theChosenNote->getFields(); + $fields['VocabKanji'] = $theChosenTerm->getKanji(); + $fields['VocabFurigana'] = $theChosenTerm->getReading(); + $fields['VocabDef'] = $theChosenTerm->toAnkiVocabDef(); + $fields['SentKanji'] = strip_tags($fields['SentKanji']); + $theChosenNote->setFields($fields); + + dd($theChosenTerm->toAnkiVocabDef(), $theChosenNote->getFields()); printf( <<request('findNotes', ['query' => $query]); + } + public function getAllSentenceListeningNoteIds(): array { $query = sprintf(