forked from CityOfPhiladelphia/eng-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_prisoners.js
40 lines (31 loc) · 1.05 KB
/
generate_prisoners.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
const faker = require('faker');
const fs = require('fs')
function generatePrisoners() {
let prisoners = []
// Testing User
prisoners.push({
"PID": 1,
"firstName": "Dorcas",
"lastName": "Kozey",
"dob": "2010-04-05",
"location": "Philadelphia"
})
for (let id=2; id <= 50; id++) {
let firstName = faker.name.firstName();
let lastName = faker.name.lastName();
const dates = ["2020-01-02", "2019-02-03", "2018-03-04", "2010-04-05"];
let dob = dates[Math.floor(Math.random() * dates.length)];
const locations = ["Philadelphia", "Newark", "Quakertown", "Lansdale", "Bethlehem", "Alcatraz"];
let location = locations[Math.floor(Math.random() * locations.length)];
prisoners.push({
"PID": id,
"firstName": firstName,
"lastName": lastName,
"dob": dob,
"location": location
});
}
return { "data": prisoners }
}
let dataObj = generatePrisoners();
fs.writeFileSync('./app/api/models/prisoners.json', JSON.stringify(dataObj, null, '\t'));