Update getMergedSecondarySearchResults to use findTermsExactBulk

This commit is contained in:
toasted-nutbread 2019-10-19 12:42:26 -04:00
parent 4446cbeabb
commit 97de7883a3

View File

@ -70,29 +70,34 @@ class Translator {
}
async getMergedSecondarySearchResults(text, expressionsMap, secondarySearchTitles) {
const secondarySearchResults = [];
if (secondarySearchTitles.length === 0) {
return secondarySearchResults;
return [];
}
const expressionList = [];
const readingList = [];
for (const expression of expressionsMap.keys()) {
if (expression === text) {
continue;
if (expression === text) { continue; }
for (const reading of expressionsMap.get(expression).keys()) {
expressionList.push(expression);
readingList.push(reading);
}
}
for (const reading of expressionsMap.get(expression).keys()) {
for (const definition of await this.database.findTermsExact(expression, reading, secondarySearchTitles)) {
const definitions = await this.database.findTermsExactBulk(expressionList, readingList, secondarySearchTitles);
for (const definition of definitions) {
const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
definitionTags.push(dictTagBuildSource(definition.dictionary));
definition.definitionTags = definitionTags;
const termTags = await this.expandTags(definition.termTags, definition.dictionary);
definition.termTags = termTags;
secondarySearchResults.push(definition);
}
}
}
return secondarySearchResults;
if (definitions.length > 1) {
definitions.sort((a, b) => a.index - b.index);
}
return definitions;
}
async getMergedDefinition(text, dictionaries, sequencedDefinition, defaultDefinitions, secondarySearchTitles, mergedByTermIndices) {