Update how frequency data is set up

This commit is contained in:
toasted-nutbread 2020-01-24 22:24:05 -05:00
parent ee41e0e42e
commit 8233119eb7

View File

@ -424,13 +424,13 @@ class Translator {
definition.frequencies = []; definition.frequencies = [];
} }
for (const meta of await this.database.findKanjiMetaBulk(kanjiList2, titles)) { const metas = await this.database.findKanjiMetaBulk(kanjiList2, titles);
if (meta.mode !== 'freq') { continue; } for (const {character, mode, data, dictionary, index} of metas) {
definitions[meta.index].frequencies.push({ switch (mode) {
character: meta.character, case 'freq':
frequency: meta.data, definitions[index].frequencies.push({character, frequency: data, dictionary});
dictionary: meta.dictionary break;
}); }
} }
return definitions; return definitions;
@ -471,17 +471,13 @@ class Translator {
} }
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles); const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);
for (const meta of metas) { for (const {expression, mode, data, dictionary, index} of metas) {
if (meta.mode !== 'freq') { switch (mode) {
continue; case 'freq':
} for (const term of termsUnique[index]) {
term.frequencies.push({expression, frequency: data, dictionary});
for (const term of termsUnique[meta.index]) { }
term.frequencies.push({ break;
expression: meta.expression,
frequency: meta.data,
dictionary: meta.dictionary
});
} }
} }
} }