-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdummyData.js
42 lines (32 loc) · 1.13 KB
/
dummyData.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
const moment = require('moment');
const faker = require('faker');
const dedupe = require('dedupe');
const roomNames = dedupe(Array.from(Array(30), _ => faker.name.jobType()));
function generateSessions() {
const countTracks = 7;
let id = 0;
const result = [];
for (var trackNumber = 0; trackNumber < countTracks; trackNumber++) {
const room = roomNames.pop();
const startTime = moment('2018-01-01 08:00:00');
const lastSession = moment('2018-01-01 16:00:00');
let currentSession = startTime.clone();
while (currentSession.isBefore(lastSession)) {
const sessionEnd = currentSession.clone().add(2, 'hours');
const title = randomTitle();
result.push({
id: id++,
title,
host: `${faker.name.firstName()} ${faker.name.lastName()}`,
room,
start: currentSession.format(),
end: sessionEnd.format()
});
currentSession = sessionEnd;
}
}
return result;
}
const toTitleCase = (title) => title.replace(/\b\w/g, l => l.toUpperCase());
const randomTitle = () => toTitleCase(faker.company.bs());
module.exports.generateSessions = generateSessions;