combine indices and stats

This commit is contained in:
Alex Yatskov 2017-09-17 19:57:39 -07:00
parent d9d16613f8
commit e90274519a
2 changed files with 8 additions and 11 deletions

View File

@ -110,7 +110,6 @@ class Database {
kunyomi: dictFieldSplit(row.kunyomi), kunyomi: dictFieldSplit(row.kunyomi),
tags: dictFieldSplit(row.tags), tags: dictFieldSplit(row.tags),
glossary: row.meanings, glossary: row.meanings,
indices: row.indices,
stats: row.stats, stats: row.stats,
dictionary: row.dictionary dictionary: row.dictionary
}); });
@ -252,14 +251,13 @@ class Database {
}); });
} }
} else { } else {
for (const [character, onyomi, kunyomi, tags, meanings, indices, stats] of entries) { for (const [character, onyomi, kunyomi, tags, meanings, stats] of entries) {
rows.push({ rows.push({
character, character,
onyomi, onyomi,
kunyomi, kunyomi,
tags, tags,
meanings, meanings,
indices,
stats, stats,
dictionary: summary.title dictionary: summary.title
}); });

View File

@ -140,8 +140,7 @@ class Translator {
tags.push(dictTagBuildSource(definition.dictionary)); tags.push(dictTagBuildSource(definition.dictionary));
definition.tags = dictTagsSort(tags); definition.tags = dictTagsSort(tags);
definition.stats = await this.expandTaggedValues(definition.stats, definition.dictionary); definition.stats = await this.expandStats(definition.stats, definition.dictionary);
definition.indices = await this.expandTaggedValues(definition.indices, definition.dictionary);
definition.frequencies = await this.database.findKanjiFreq(definition.character, titles); definition.frequencies = await this.database.findKanjiFreq(definition.character, titles);
} }
@ -174,22 +173,22 @@ class Translator {
return tags; return tags;
} }
async expandTaggedValues(items, title) { async expandStats(items, title) {
const tags = []; const stats = [];
for (const name in items) { for (const name in items) {
const base = name.split(':')[0]; const base = name.split(':')[0];
const meta = await this.database.findTagForTitle(base, title); const meta = await this.database.findTagForTitle(base, title);
const tag = {name, value: items[name]}; const stat = {name, value: items[name]};
for (const prop in meta || {}) { for (const prop in meta || {}) {
if (prop !== 'name') { if (prop !== 'name') {
tag[prop] = meta[prop]; stat[prop] = meta[prop];
} }
} }
tags.push(dictTagSanitize(tag)); stats.push(dictTagSanitize(stat));
} }
return tags; return stats;
} }
} }