aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-24 22:24:05 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-01-24 22:24:05 -0500
commit8233119eb7b15099da310dbd46f005ee678e42ca (patch)
tree1ca1eb147cac2cfa755b55422da4071712722400 /ext
parentee41e0e42e620f86107efe9c5433b2c61c37e612 (diff)
Update how frequency data is set up
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/translator.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index e5e34ed8..ebb02687 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -424,13 +424,13 @@ class Translator {
definition.frequencies = [];
}
- for (const meta of await this.database.findKanjiMetaBulk(kanjiList2, titles)) {
- if (meta.mode !== 'freq') { continue; }
- definitions[meta.index].frequencies.push({
- character: meta.character,
- frequency: meta.data,
- dictionary: meta.dictionary
- });
+ const metas = await this.database.findKanjiMetaBulk(kanjiList2, titles);
+ for (const {character, mode, data, dictionary, index} of metas) {
+ switch (mode) {
+ case 'freq':
+ definitions[index].frequencies.push({character, frequency: data, dictionary});
+ break;
+ }
}
return definitions;
@@ -471,17 +471,13 @@ class Translator {
}
const metas = await this.database.findTermMetaBulk(expressionsUnique, titles);
- for (const meta of metas) {
- if (meta.mode !== 'freq') {
- continue;
- }
-
- for (const term of termsUnique[meta.index]) {
- term.frequencies.push({
- expression: meta.expression,
- frequency: meta.data,
- dictionary: meta.dictionary
- });
+ for (const {expression, mode, data, dictionary, index} of metas) {
+ switch (mode) {
+ case 'freq':
+ for (const term of termsUnique[index]) {
+ term.frequencies.push({expression, frequency: data, dictionary});
+ }
+ break;
}
}
}