* dev: (85 commits) chore: console.log debug leftovers fix: third level navigation links fix: show subheader on refresh fix: machines/:id routing fix: customer route chore: update wallet nodes feat: shorten long addresses in funding page feat: shorten long addresses refactor: support copied text different from presented text chore: udpate react, downshift and routing refactor: use Wizard component on first route fix: autocomplete component rendering feat: skip2fa option on .env fix: drop contraint before dropping index chore: stop using alias imports fix: re-instate urlResolver chore: server code formatting chore: reformat code chore: adding eslint and prettier config chore: typo ...
89 lines
2.9 KiB
JavaScript
89 lines
2.9 KiB
JavaScript
const _ = require('lodash/fp')
|
|
const {
|
|
migrationSaveConfig,
|
|
loadLatestConfig,
|
|
} = require('../lib/new-settings-loader')
|
|
const CASSETTE_MAX_CAPACITY = 500
|
|
|
|
exports.up = function (next) {
|
|
return loadLatestConfig()
|
|
.then(config => {
|
|
const fiatBalance1 = config.notifications_fiatBalanceCassette1
|
|
const fiatBalance2 = config.notifications_fiatBalanceCassette2
|
|
const fiatBalance3 = config.notifications_fiatBalanceCassette3
|
|
const fiatBalance4 = config.notifications_fiatBalanceCassette4
|
|
const overrides = config.notifications_fiatBalanceOverrides
|
|
const newConfig = {}
|
|
if (fiatBalance1) {
|
|
newConfig.notifications_fillingPercentageCassette1 = (
|
|
100 *
|
|
(fiatBalance1 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
newConfig.notifications_fiatBalanceCassette1 = null
|
|
}
|
|
if (fiatBalance2) {
|
|
newConfig.notifications_fillingPercentageCassette2 = (
|
|
100 *
|
|
(fiatBalance2 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
newConfig.notifications_fiatBalanceCassette2 = null
|
|
}
|
|
if (fiatBalance3) {
|
|
newConfig.notifications_fillingPercentageCassette3 = (
|
|
100 *
|
|
(fiatBalance3 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
newConfig.notifications_fiatBalanceCassette3 = null
|
|
}
|
|
if (fiatBalance4) {
|
|
newConfig.notifications_fillingPercentageCassette4 = (
|
|
100 *
|
|
(fiatBalance4 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
newConfig.notifications_fiatBalanceCassette4 = null
|
|
}
|
|
|
|
if (overrides) {
|
|
newConfig.notifications_fiatBalanceOverrides = _.map(override => {
|
|
const newOverride = {}
|
|
if (override.fiatBalanceCassette1) {
|
|
newOverride.fillingPercentageCassette1 = (
|
|
100 *
|
|
(override.fiatBalanceCassette1 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
}
|
|
if (override.fiatBalanceCassette2) {
|
|
newOverride.fillingPercentageCassette2 = (
|
|
100 *
|
|
(override.fiatBalanceCassette2 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
}
|
|
if (override.fiatBalanceCassette3) {
|
|
newOverride.fillingPercentageCassette3 = (
|
|
100 *
|
|
(override.fiatBalanceCassette3 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
}
|
|
if (override.fiatBalanceCassette4) {
|
|
newOverride.fillingPercentageCassette4 = (
|
|
100 *
|
|
(override.fiatBalanceCassette4 / CASSETTE_MAX_CAPACITY)
|
|
).toFixed(0)
|
|
}
|
|
newOverride.machine = override.machine
|
|
newOverride.id = override.id
|
|
|
|
return newOverride
|
|
}, config.notifications_fiatBalanceOverrides)
|
|
}
|
|
return migrationSaveConfig(newConfig).then(() => next())
|
|
})
|
|
.catch(err => {
|
|
console.log(err.message)
|
|
return next(err)
|
|
})
|
|
}
|
|
|
|
module.exports.down = function (next) {
|
|
next()
|
|
}
|