Skip to content

Commit

Permalink
micro-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Jan 13, 2021
1 parent 19d405a commit c0ab59d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/data-generator/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
export default (db, { serializeDate }) => {
const today = new Date();
const aMonthAgo = subDays(today, 30);
const realCustomers = db.customers.filter(customer => customer.has_ordered);

return Array.from(Array(600).keys()).map(id => {
const nbProducts = weightedArrayElement(
Expand All @@ -35,9 +36,7 @@ export default (db, { serializeDate }) => {
const taxes = parseFloat(
((total_ex_taxes + delivery_fees) * tax_rate).toFixed(2)
);
const customer = random.arrayElement(
db.customers.filter(customer => customer.has_ordered)
);
const customer = random.arrayElement(realCustomers);
const date = randomDate(customer.first_seen, customer.last_seen);

const status =
Expand Down

0 comments on commit c0ab59d

Please sign in to comment.