Store new dictionary data

This commit is contained in:
toasted-nutbread 2020-04-05 14:45:54 -04:00
parent cd831d88cc
commit 1b97629cd8

View File

@ -150,13 +150,7 @@ class DictionaryImporter {
} }
// Add dictionary // Add dictionary
const summary = { const summary = this._createSummary(dictionaryTitle, version, index, {prefixWildcardsSupported});
title: dictionaryTitle,
revision: index.revision,
sequenced: index.sequenced,
version,
prefixWildcardsSupported
};
database.bulkAdd('dictionaries', [summary], 0, 1); database.bulkAdd('dictionaries', [summary], 0, 1);
@ -199,6 +193,25 @@ class DictionaryImporter {
return {result: summary, errors}; return {result: summary, errors};
} }
_createSummary(dictionaryTitle, version, index, details) {
const summary = {
title: dictionaryTitle,
revision: index.revision,
sequenced: index.sequenced,
version
};
const {author, url, description, attribution} = index;
if (typeof author === 'string') { summary.author = author; }
if (typeof url === 'string') { summary.url = url; }
if (typeof description === 'string') { summary.description = description; }
if (typeof attribution === 'string') { summary.attribution = attribution; }
Object.assign(summary, details);
return summary;
}
async _getSchema(fileName) { async _getSchema(fileName) {
let schemaPromise = this._schemas.get(fileName); let schemaPromise = this._schemas.get(fileName);
if (typeof schemaPromise !== 'undefined') { if (typeof schemaPromise !== 'undefined') {