fix: merge two conditionals
This commit is contained in:
parent
e919a54c87
commit
240203b060
1 changed files with 6 additions and 14 deletions
|
|
@ -82,12 +82,15 @@ const populateSettings = function (req, res, next) {
|
||||||
|
|
||||||
const operatorSettings = settingsCache.get(`${operatorId}-latest`)
|
const operatorSettings = settingsCache.get(`${operatorId}-latest`)
|
||||||
|
|
||||||
if (!versionId && !!needsSettingsReload[operatorId]) {
|
if (!versionId && (!!needsSettingsReload[operatorId] || !operatorSettings)) {
|
||||||
logger.debug('Fetching and caching a new latest config value, as a reload was requested')
|
!!needsSettingsReload[operatorId]
|
||||||
|
? logger.debug('Fetching and caching a new latest config value, as a reload was requested')
|
||||||
|
: logger.debug('Fetching the latest config version because there\'s no cached value')
|
||||||
|
|
||||||
return newSettingsLoader.loadLatest()
|
return newSettingsLoader.loadLatest()
|
||||||
.then(settings => {
|
.then(settings => {
|
||||||
settingsCache.set(`${operatorId}-latest`, settings)
|
settingsCache.set(`${operatorId}-latest`, settings)
|
||||||
delete needsSettingsReload[operatorId]
|
if (!!needsSettingsReload[operatorId]) delete needsSettingsReload[operatorId]
|
||||||
req.settings = settings
|
req.settings = settings
|
||||||
})
|
})
|
||||||
.then(() => next())
|
.then(() => next())
|
||||||
|
|
@ -99,17 +102,6 @@ const populateSettings = function (req, res, next) {
|
||||||
req.settings = operatorSettings
|
req.settings = operatorSettings
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!versionId && !operatorSettings) {
|
|
||||||
logger.debug('Fetching the latest config version because there\'s no cached value')
|
|
||||||
return newSettingsLoader.loadLatest()
|
|
||||||
.then(settings => {
|
|
||||||
settingsCache.set(`${operatorId}-latest`, settings)
|
|
||||||
req.settings = settings
|
|
||||||
})
|
|
||||||
.then(() => next())
|
|
||||||
.catch(next)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue