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`)
|
||||
|
||||
if (!versionId && !!needsSettingsReload[operatorId]) {
|
||||
logger.debug('Fetching and caching a new latest config value, as a reload was requested')
|
||||
if (!versionId && (!!needsSettingsReload[operatorId] || !operatorSettings)) {
|
||||
!!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()
|
||||
.then(settings => {
|
||||
settingsCache.set(`${operatorId}-latest`, settings)
|
||||
delete needsSettingsReload[operatorId]
|
||||
if (!!needsSettingsReload[operatorId]) delete needsSettingsReload[operatorId]
|
||||
req.settings = settings
|
||||
})
|
||||
.then(() => next())
|
||||
|
|
@ -99,17 +102,6 @@ const populateSettings = function (req, res, next) {
|
|||
req.settings = operatorSettings
|
||||
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) {
|
||||
logger.error(e)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue