moved l-a-s in here

This commit is contained in:
Josh Harvey 2016-12-05 17:15:32 +02:00
parent 1e3e55e362
commit 836ab07776
18 changed files with 3946 additions and 281 deletions

24
tools/currencies.js Normal file
View file

@ -0,0 +1,24 @@
// Pull latest from: http://www.currency-iso.org/en/home/tables/table-a1.html
// Convert to JSON at: http://www.csvjson.com/csv2json
const R = require('ramda')
const currencies = require('../currencies.json')
function goodCurrency (currency) {
const code = currency.code
return code.length === 3 && code[0] !== 'X'
}
function simplify (currency) {
return {
code: currency['Alphabetic Code'],
display: currency['Currency']
}
}
function toElmItem (currency) {
return `{ code = "${currency.code}"
, display = "${currency.display}"
, searchWords = []
}`
}

40
tools/modify.js Normal file
View file

@ -0,0 +1,40 @@
'use strict'
const R = require('ramda')
const db = require('../db')
function pp (o) {
console.log(require('util').inspect(o, {depth: null, colors: true}))
}
function dbFetchConfig () {
return db.oneOrNone('select data from user_config where type=$1', ['config'])
.then(row => row && row.data)
}
dbFetchConfig()
.then(c => {
const groups = c.groups
.filter(g => g.code !== 'fiat')
.map(g => {
if (g.code === 'currencies') {
const values = g.values.filter(v => v.fieldLocator.code !== 'cryptoCurrencies')
return R.assoc('values', values, g)
}
return g
})
return {groups: groups}
})
.then(config => {
pp(config)
return db.none('update user_config set data=$1 where type=$2', [config, 'config'])
})
.then(() => {
process.exit(0)
})
.catch(e => {
console.log(e)
process.exit(1)
})

22
tools/show.js Normal file
View file

@ -0,0 +1,22 @@
'use strict'
const db = require('../lib/db')
function pp (o) {
console.log(require('util').inspect(o, {depth: null, colors: true}))
}
function dbFetchConfig () {
return db.oneOrNone('select data from user_config where type=$1', ['config'])
.then(row => row && row.data)
}
dbFetchConfig()
.then(config => {
pp(config)
process.exit(0)
})
.catch(e => {
console.log(e)
process.exit(1)
})