Skip to content

Commit

Permalink
chore(deps-dev): bump standard from 12.0.1 to 16.0.3 (#78)
Browse files Browse the repository at this point in the history
Bumps [standard](https://github.com/standard/standard) from 12.0.1 to 16.0.3.
- [Release notes](https://github.com/standard/standard/releases)
- [Changelog](https://github.com/standard/standard/blob/master/CHANGELOG.md)
- [Commits](standard/standard@v12.0.1...v16.0.3)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Trent Mick <[email protected]>
  • Loading branch information
dependabot[bot] and trentm authored Apr 12, 2021
1 parent f48c9b4 commit 669dafb
Show file tree
Hide file tree
Showing 11 changed files with 709 additions and 721 deletions.
34 changes: 17 additions & 17 deletions db/generate_orders.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
'use strict'

var pg = require('pg')
var afterAll = require('after-all-results')
var conf = require('../server/config')
const pg = require('pg')
const afterAll = require('after-all-results')
const conf = require('../server/config')

var amount = parseInt(process.argv[2], 10)
const amount = parseInt(process.argv[2], 10)

if (!amount) throw new Error('Amount not specified!')

var client = new pg.Client(conf.pg)
const client = new pg.Client(conf.pg)

client.connect(function (err) {
if (err) throw err

var next = afterAll(function (err, results) {
const next = afterAll(function (err, results) {
if (err) throw err

var products = results[0].rows
var customers = results[1].rows
const products = results[0].rows
const customers = results[1].rows

var next = afterAll(function (err) {
const next = afterAll(function (err) {
if (err) throw err
client.end(function (err) {
if (err) throw err
})
})

for (var n = 0; n < amount; n++) {
for (let n = 0; n < amount; n++) {
createOrder(randomId(customers), randomOrderLines(products), next())
}
})
Expand All @@ -35,13 +35,13 @@ client.connect(function (err) {
client.query('SELECT id FROM customers', next())

function createOrder (customer, lines, cb) {
var sql = 'INSERT INTO orders (customer_id) VALUES ($1) RETURNING id'
const sql = 'INSERT INTO orders (customer_id) VALUES ($1) RETURNING id'
client.query(sql, [customer], function (err, result) {
if (err) return cb(err)
var next = afterAll(cb)
var id = result.rows[0].id
const next = afterAll(cb)
const id = result.rows[0].id
lines.forEach(function (line) {
var sql = 'INSERT INTO order_lines (order_id, product_id, amount) VALUES ($1, $2, $3)'
const sql = 'INSERT INTO order_lines (order_id, product_id, amount) VALUES ($1, $2, $3)'
client.query(sql, [id, line.id, line.amount], next())
})
})
Expand All @@ -62,9 +62,9 @@ function randomId (arr) {
}

function randomOrderLines (products) {
var amount = random(8)
var result = []
for (var n = 0; n < amount; n++) {
const amount = random(8)
const result = []
for (let n = 0; n < amount; n++) {
result.push({
id: randomId(products),
amount: random(3)
Expand Down
Loading

0 comments on commit 669dafb

Please sign in to comment.