refactor: remove unnecessary query parameters
This commit is contained in:
parent
3a548fea6f
commit
437a1d3505
1 changed files with 13 additions and 12 deletions
|
|
@ -161,13 +161,13 @@ function loadLatest (schemaVersion) {
|
|||
function loadLatestConfig () {
|
||||
const sql = `SELECT data
|
||||
FROM user_config
|
||||
WHERE type = $1
|
||||
AND schema_version = $2
|
||||
WHERE type = 'config'
|
||||
AND schema_version = $1
|
||||
AND valid
|
||||
ORDER BY id DESC
|
||||
LIMIT 1`
|
||||
|
||||
return db.one(sql, ['config', NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
return db.one(sql, [NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(row => row ? row.data.config : {})
|
||||
.catch(err => {
|
||||
throw err
|
||||
|
|
@ -177,24 +177,25 @@ function loadLatestConfig () {
|
|||
function loadLatestConfigOrNoneReturningVersion (schemaVersion) {
|
||||
const sql = `SELECT data, id
|
||||
FROM user_config
|
||||
WHERE type = $1
|
||||
AND schema_version = $2
|
||||
WHERE type = 'config'
|
||||
AND schema_version = $1
|
||||
AND valid
|
||||
ORDER BY id DESC
|
||||
LIMIT 1`
|
||||
|
||||
return db.oneOrNone(sql, ['config', schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
return db.oneOrNone(sql, [schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(row => row ? { config: row.data.config, version: row.id } : {})
|
||||
}
|
||||
|
||||
function loadLatestConfigOrNone (schemaVersion) {
|
||||
const sql = `SELECT data
|
||||
FROM user_config
|
||||
WHERE type = $1
|
||||
AND schema_version = $2
|
||||
WHERE type = 'config'
|
||||
AND schema_version = $1
|
||||
ORDER BY id DESC
|
||||
LIMIT 1`
|
||||
|
||||
return db.oneOrNone(sql, ['config', schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
return db.oneOrNone(sql, [schemaVersion || NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(row => row ? row.data.config : {})
|
||||
}
|
||||
|
||||
|
|
@ -202,11 +203,11 @@ function loadConfig (versionId) {
|
|||
const sql = `SELECT data
|
||||
FROM user_config
|
||||
WHERE id = $1
|
||||
AND type = $2
|
||||
AND schema_version = $3
|
||||
AND type = 'config'
|
||||
AND schema_version = $2
|
||||
AND valid`
|
||||
|
||||
return db.one(sql, [versionId, 'config', NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
return db.one(sql, [versionId, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(row => row.data.config)
|
||||
.catch(err => {
|
||||
if (err.name === 'QueryResultError') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue