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 () {
|
function loadLatestConfig () {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = $1
|
WHERE type = 'config'
|
||||||
AND schema_version = $2
|
AND schema_version = $1
|
||||||
AND valid
|
AND valid
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT 1`
|
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 : {})
|
.then(row => row ? row.data.config : {})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
throw err
|
throw err
|
||||||
|
|
@ -177,24 +177,25 @@ function loadLatestConfig () {
|
||||||
function loadLatestConfigOrNoneReturningVersion (schemaVersion) {
|
function loadLatestConfigOrNoneReturningVersion (schemaVersion) {
|
||||||
const sql = `SELECT data, id
|
const sql = `SELECT data, id
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = $1
|
WHERE type = 'config'
|
||||||
AND schema_version = $2
|
AND schema_version = $1
|
||||||
|
AND valid
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT 1`
|
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 } : {})
|
.then(row => row ? { config: row.data.config, version: row.id } : {})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLatestConfigOrNone (schemaVersion) {
|
function loadLatestConfigOrNone (schemaVersion) {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE type = $1
|
WHERE type = 'config'
|
||||||
AND schema_version = $2
|
AND schema_version = $1
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT 1`
|
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 : {})
|
.then(row => row ? row.data.config : {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,11 +203,11 @@ function loadConfig (versionId) {
|
||||||
const sql = `SELECT data
|
const sql = `SELECT data
|
||||||
FROM user_config
|
FROM user_config
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
AND type = $2
|
AND type = 'config'
|
||||||
AND schema_version = $3
|
AND schema_version = $2
|
||||||
AND valid`
|
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)
|
.then(row => row.data.config)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.name === 'QueryResultError') {
|
if (err.name === 'QueryResultError') {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue