Liordino feature/config migration review (#552)
* feat: changed old server ports so it can coexists with the new server feat: removed deleted references from old server feat: created reset and migrate mutations on gql server and correspondent functions on new settings loader feat: created front end for the config migration with reset and migrate functionalities style: add spacing between buttons * feat: added ALL_COINS option to the commissions migration fix: only compare arrays when both variables are arrays fix: 'all coins' must be on a array to work Signed-off-by: Liordino Neto <liordinoneto@gmail.com> Co-authored-by: Liordino Neto <liordinoneto@gmail.com>
This commit is contained in:
parent
9ed3bc50e4
commit
e843020215
2 changed files with 3 additions and 3 deletions
|
|
@ -5,6 +5,7 @@ const { scopedValue } = require('./admin/config-manager')
|
||||||
|
|
||||||
const GLOBAL = 'global'
|
const GLOBAL = 'global'
|
||||||
const ALL_CRYPTOS = _.values(COINS).sort()
|
const ALL_CRYPTOS = _.values(COINS).sort()
|
||||||
|
const ALL_CRYPTOS_STRING = 'ALL_COINS'
|
||||||
const ALL_MACHINES = 'ALL_MACHINES'
|
const ALL_MACHINES = 'ALL_MACHINES'
|
||||||
|
|
||||||
const GLOBAL_SCOPE = {
|
const GLOBAL_SCOPE = {
|
||||||
|
|
@ -66,7 +67,7 @@ function getConfigFields (codes, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateCommissions (config) {
|
function migrateCommissions (config) {
|
||||||
const areArraysEquals = (arr1, arr2) => _.isEmpty(_.xor(arr1, arr2))
|
const areArraysEquals = (arr1, arr2) => Array.isArray(arr1) && Array.isArray(arr2) && _.isEmpty(_.xor(arr1, arr2))
|
||||||
const getMachine = _.get('scope.machine')
|
const getMachine = _.get('scope.machine')
|
||||||
const getCrypto = _.get('scope.crypto')
|
const getCrypto = _.get('scope.crypto')
|
||||||
const flattenCoins = _.compose(_.flatten, _.map(getCrypto))
|
const flattenCoins = _.compose(_.flatten, _.map(getCrypto))
|
||||||
|
|
@ -116,7 +117,7 @@ function migrateCommissions (config) {
|
||||||
commissions_overrides: allCommissionsOverrides.map(s => ({
|
commissions_overrides: allCommissionsOverrides.map(s => ({
|
||||||
..._.fromPairs(s.values.map(f => [codes[f.code], f.value])),
|
..._.fromPairs(s.values.map(f => [codes[f.code], f.value])),
|
||||||
machine: s.scope.machine === GLOBAL ? ALL_MACHINES : s.scope.machine,
|
machine: s.scope.machine === GLOBAL ? ALL_MACHINES : s.scope.machine,
|
||||||
cryptoCurrencies: s.scope.crypto,
|
cryptoCurrencies: areArraysEquals(s.scope.crypto, ALL_CRYPTOS) ? [ALL_CRYPTOS_STRING] : s.scope.crypto,
|
||||||
id: uuid.v4()
|
id: uuid.v4()
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ function loadAccounts (schemaVersion) {
|
||||||
|
|
||||||
const configSql = 'insert into user_config (type, data, valid, schema_version) values ($1, $2, $3, $4)'
|
const configSql = 'insert into user_config (type, data, valid, schema_version) values ($1, $2, $3, $4)'
|
||||||
function saveConfig (config) {
|
function saveConfig (config) {
|
||||||
console.log(config)
|
|
||||||
return loadLatestConfigOrNone()
|
return loadLatestConfigOrNone()
|
||||||
.then(currentConfig => {
|
.then(currentConfig => {
|
||||||
const newConfig = _.assign(currentConfig, config)
|
const newConfig = _.assign(currentConfig, config)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue