-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate.js
76 lines (70 loc) · 1.52 KB
/
generate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const fs = require('fs');
const faker = require('faker');
const VENDORS = [
{
name: "Prop Labs Kolsch Beer Yeast",
ingredients: ["YEAST"],
source: {
api: "REST",
frequency: "Daily"
}
},
{
name: "Crudo Ogliarolo",
ingredients: ["OLIVE_OIL"],
source: {
api: "PHONE",
frequency: "Sporadic"
}
},
{
name: "San Marzano Whole Tomatoes",
ingredients: ["TOMATOES"],
source: {
api: "WEBHOOK",
frequency: "Live"
}
},
{
name: "Sonoma Farms",
ingredients: ["MOZZARELLA", "OLIVE_OIL"],
source: {
api: "SMS",
frequency: "Sporadic"
}
},
{
name: "Oakland Farmer's Market",
ingredients: ["BASIL", "TOMATOES"],
source: {
api: "EMAIL",
frequency: "Seasonal"
}
},
]
const QUALITY = ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'D', 'F'];
const entries = Array(50).fill(0).map((_, i) => {
const date = faker.date.between('2021-01-01', '2021-06-30');
const vendor = faker.random.arrayElement(VENDORS);
const ingredient = faker.random.arrayElement(vendor.ingredients);
const quality = faker.random.arrayElement(QUALITY);
const count = faker.datatype.number(200);
const notes = faker.company.catchPhrase();
const verify = faker.datatype.boolean();
return {
date,
ingredient,
count,
quality,
vendor,
notes,
verify
}
});
fs.writeFile('./pages/api/entries.json', JSON.stringify(entries), err => {
if (err) {
console.error(err)
return
}
//file written successfully
})