This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const generateTable = (table_name, columns, data) => { | |
| return knex.transaction((trx) => { | |
| return trx.schema.dropTableIfExists(table_name) | |
| .then(() => { | |
| return trx.schema.createTable(table_name, (tbl) => { | |
| tbl.increments('id') | |
| columns.map(key => { | |
| key === 'user_id' | |
| ? tbl.integer(key) | |
| : tbl.string(key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| knex.transaction(trx => { | |
| let data = [1,2,3,4,5,6,7,8,9] | |
| data.map(item => { | |
| trx.insert(item) | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const config = require('./config.json') | |
| let url = `amqp://${config.AMQP_USER}:${config.AMQP_PASS}@${config.AMQP_HOST}:${config.AMQP_PORT}`; | |
| let rabbitMQDetails = { | |
| url: url, | |
| exchange: config.AMQP_SEND_EXCHANGE, | |
| exchangeType: config.AMQP_TOPIC, | |
| routingKey: '', | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| title: 'Meltano', | |
| description: 'From data source to dashboard', | |
| themeConfig: { | |
| sidebar: ['foo', 'bar', 'hello', 'world'], | |
| displayAllHeaders: true, | |
| nav: [{ text: 'Home', link: '/' }, { text: 'About', link: '/about/' }, { text: 'Resources', link: '/resources/' }], | |
| repo: 'https://gitlab.com/meltano/meltano', | |
| repoLabel: 'Repo', | |
| docsDir: 'src', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // # assuming you're passing in an object array of filters | |
| // # [{date: '01/01/2018'}, {number: 5}, {status: 'active'}, {userID: 1234}] | |
| exports.getArticles = async function (filters) { | |
| const query = knex('articles').select() | |
| Object.key(filters).map(key => { | |
| switch(key) { | |
| case 'date': | |
| query.where(key, '<', filters[key]) | |
| default: | |
| query.where(key, filters[key]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // # your original | |
| exports.getArticles = async function (date, number = 4, status, userID) { | |
| const query = knex('articles') | |
| if (date) { | |
| query.where('date', '<', date) | |
| } | |
| if (status) { | |
| query.where(status, status) | |
| } | |
| if (userID) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const get_token = (count) => { | |
| return fetch(url).then(res => { | |
| if(res.status !== 200) throw 'failed' | |
| else return res.headers.get('token') | |
| }) | |
| .catch(e => { | |
| console.log(count) | |
| count++; | |
| if(count < 3) get_token(count) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 4d,50,53,37,01,00,00,00,47, | |
| 00,53,09,27,d1,39,67,47,c0,45,d9,91,21,40,82,e2,31,d6,d7,2e,8d, | |
| 01,54,6d,71,6a,14,a2,b0,f5,d4,bb,8f,e2,40,89,c9,09,73,81,93,6a, | |
| 00,53,55,f0,20,0e,24,8b,51,4e,16,00,e7,40,84,e5,62,67,53,65,36, | |
| 02,52,e1,f4,bb,33,af,d3,79,41,43,90,89, | |
| 00,54,72,0d,ac,5e,e2,de,ba,a8,58,bf,74,40,78,db,d1,f8,00,c4,3a, | |
| 01,54,6c,ee,a5,6e,be,0d,e7,c0,f8,f4,f6,40,83,01,13,0c,24,4c,da, | |
| 02,53,e8,3c,ba,02,5b,10,42,9c,7d,52,fd, | |
| 00,53,dd,fc,f4,5a,f9,a8,10,8c,0c,9b,ee,40,64,6a,81,ed,e3,ee,df, | |
| 00,54,6f,d5,fe,5e,b2,9c,77,19,af,53,ba,40,78,09,de,08,e0,7b,76, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rates: | |
| [ '290.6', | |
| '296.75', | |
| '306.07', | |
| '333.06', | |
| '335.81', | |
| '344.01', | |
| '354.59', | |
| '362.92', | |
| '364.99', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let populateTables = () => { | |
| // return knex('plans').insert({state:'testing'}) | |
| return knex.transaction(trx => { | |
| fs.createReadStream('./plans.csv') | |
| .pipe(csv()) | |
| .on('data', data => { | |
| return trx.insert(data).into('plans') | |
| }) | |
| .on('end', data => { |