forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeeting.js
More file actions
677 lines (623 loc) · 20.7 KB
/
Copy pathmeeting.js
File metadata and controls
677 lines (623 loc) · 20.7 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
const { DateTime } = require('luxon')
const { faker } = require('@faker-js/faker')
const seedrandom = require('seedrandom')
const _ = require('lodash')
const slugify = require('slugify')
const ms = require('ms')
const floorsMeta = require('../data/meeting-floors')
const urlRe = /http[s]?:\/\/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/
const conferenceDomains = ['webex.com', 'zoom.us', 'jitsi.org', 'meetecho.com', 'gather.town']
const xslugify = (str) => slugify(str.replace('/', '-'), { lower: true, strict: true })
const TEST_SEED = 123
const sessionsWithNotes = [3, 6, 20, 48, 49, 60]
const sessionsCancelled = [29, 93]
const sessionsRescheduled = [76]
const sessionsMissingAgenda = [5, 10]
const sessionsWithWebex = [3, 4]
// Use constant randomness seed
seedrandom(TEST_SEED.toString(), { global: true })
faker.seed(TEST_SEED)
const { random, sample, sampleSize } = _.runInContext()
/**
* Generate area response from label + children
*/
function createArea ({ label, children = [] }) {
return {
label,
keyword: xslugify(label),
toggled_by: [],
is_bof: false,
children: children.map(gr => {
gr.toggled_by.push(xslugify(label))
return gr
})
}
}
/**
* Generate group response from label
*/
const uniqueGroupNames = []
function createGroup ({ label, mayBeBof = false, toggledBy = [] }) {
// make sure group name is unique
while (!label) {
const nameAttempt = faker.word.verb()
if (!uniqueGroupNames.includes(nameAttempt)) {
label = nameAttempt
uniqueGroupNames.push(nameAttempt)
}
}
// Set toggledBy
if (!toggledBy) {
toggledBy = []
}
// 10% chance of BoF, if enabled
const isBof = mayBeBof && random(0, 100) < 10
if (isBof) {
toggledBy.push('bof')
}
return {
label,
keyword: xslugify(label),
toggled_by: toggledBy,
is_bof: isBof
}
}
/**
* Find area and group based on group slug
*/
function findAreaGroup (slug, areas) {
for (const area of areas) {
for (const group of area.children) {
if (group.keyword === slug) {
return { area, group }
}
}
}
throw new Error('Requested group does not exist!')
}
/**
* Reverse areas and groups mapping
*/
function reverseAreaGroupsMapping (areas) {
const groups = []
for (const area of areas) {
for (const group of area.children) {
groups.push({
...group,
area
})
}
}
return groups
}
function getEventStatus (idx) {
if (sessionsCancelled.includes(idx)) {
return 'canceled'
} else if (sessionsRescheduled.includes(idx)) {
return 'resched'
} else {
return 'sched'
}
}
/**
* Generate event
*/
let lastEventId = 100000
let lastSessionId = 25000
let lastRecordingId = 150000
function createEvent ({
name = '',
slotName = '',
startDateTime,
duration = '1h',
area,
group,
type = 'other',
status = 'sched',
hasLocation = true,
hasNote = false,
hasAgenda = false,
showAgenda = false,
hasRecordings = false,
hasVideoStream = true,
hasWebex = false,
isBoF = false
}, floors) {
const floor = sample(floors)
const room = hasLocation ? sample(floor.rooms) : { name: 'Somewhere' }
const eventName = name ?? faker.lorem.sentence(random(2, 5))
return {
id: ++lastEventId,
sessionId: ++lastSessionId,
room: room.name,
location: hasLocation
? {
short: floor.short,
name: floor.name
}
: {},
acronym: group.keyword,
duration: typeof duration === 'string' ? ms(duration) / 1000 : duration,
name: eventName,
slotName: slotName,
startDateTime: startDateTime.toISO({ includeOffset: false, suppressMilliseconds: true }),
status,
type,
isBoF,
filterKeywords: [
'coding',
'hackathon',
'hackathon-sessc'
],
groupAcronym: group.keyword,
groupName: faker.lorem.sentence(random(2, 5)),
groupParent: {
acronym: area.keyword
},
note: (hasNote || status === 'resched') ? faker.lorem.sentence(4) : '',
remoteInstructions: '',
flags: {
agenda: hasAgenda,
showAgenda
},
agenda: {
url: hasAgenda ? 'https://datatracker.ietf.org/meeting/123/materials/agenda-123-ietf-sessa-00' : null
},
orderInMeeting: 1,
short: eventName,
sessionToken: 'sessa',
links: {
chat: `https://zulip.ietf.org/#narrow/stream/${group.keyword}`,
chatArchive: `https://zulip.ietf.org/#narrow/stream/${group.keyword}`,
recordings: hasRecordings
? [
{
id: ++lastRecordingId,
name: `recording-123-${group.keyword}-1`,
title: `Video recording for ${group.keyword} on ${startDateTime.toFormat('yyyy-LL-dd \'at\' HH:mm:ss')}`,
url: 'https://www.youtube.com/watch?v=1eq_5xvacl0'
}
]
: [],
videoStream: showAgenda && hasVideoStream ? 'https://meetings.conf.meetecho.com/ietf{meeting.number}/?group={group.acronym}&short={short}&item={order_number}' : null,
audioStream: hasAgenda ? 'https://mp3.conf.meetecho.com/ietf123/{group.acronym}/{order_number}.m3u' : null,
webex: hasWebex ? 'https://webex.com/123' : null,
onsiteTool: hasAgenda ? 'https://meetings.conf.meetecho.com/onsite{meeting.number}/?group={group.acronym}&short={short}&item={order_number}' : null,
calendar: `/meeting/123/session/${lastSessionId}.ics`
}
}
}
module.exports = {
/**
* Generate a standard agenda data reponse
*/
generateAgendaResponse ({ dateMode = 'past', skipSchedule = false } = {}) {
// Get random date but always start on a saturday
let startDate = null
switch (dateMode) {
case 'current': {
startDate = DateTime.fromISO('2022-02-01T13:45:15', { zone: 'Asia/Tokyo' }).startOf('week').minus({ days: 2 })
break
}
case 'future': {
startDate = DateTime.fromISO(faker.date.future({ years: 1 }).toISOString(), { zone: 'Asia/Tokyo' }).startOf('week').minus({ days: 2 })
break
}
default: {
startDate = DateTime.fromISO(faker.date.past({ years: 5, refDate: DateTime.utc().minus({ months: 3 }) }).toISOString(), { zone: 'Asia/Tokyo' }).startOf('week').minus({ days: 2 })
break
}
}
const endDate = startDate.plus({ days: 7 })
// Generate floors
const floors = _.times(6, (idx) => {
const floorIdx = idx + 1
const floor = floorsMeta[idx]
return {
id: floorIdx,
image: `/media/floor/${floor.path}`,
name: `Level ${_.startCase(faker.color.human())} ${floorIdx}`,
short: `L${floorIdx}`,
width: floor.width,
height: floor.height,
rooms: _.times(random(5, 10), (ridx) => {
const roomName = `${faker.science.chemicalElement().name} ${floorIdx}-${ridx + 1}`
// Keep 10% margin on each side
const roomXUnit = Math.round(floor.width / 10)
const roomYUnit = Math.round(floor.height / 10)
const roomX = random(roomXUnit, roomXUnit * 8)
const roomY = random(roomYUnit, roomYUnit * 8)
return {
id: floorIdx * 100 + ridx,
name: roomName,
functionalName: _.startCase(faker.lorem.words(2)),
slug: xslugify(roomName),
left: roomX,
right: roomX + roomXUnit,
top: roomY,
bottom: roomY + roomYUnit
}
})
}
})
// Generate categories (groups/areas)
const categories = []
if (!skipSchedule) {
// Generate first group of areas
// -----------------------------
const firstAreas = []
const firstAreasNames = ['ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQR', 'STU']
for (const area of firstAreasNames) {
firstAreas.push(createArea({
label: area,
children: _.times(random(2, 25), (idx) => {
return createGroup({ mayBeBof: true })
})
}))
}
categories.push(firstAreas)
// Generate second group of areas
// ------------------------------
const secondAreas = []
for (const area of ['UVW', 'XYZ0']) {
secondAreas.push(createArea({
label: area,
children: _.times(random(2, 25), (idx) => {
return createGroup({ mayBeBof: true })
})
}))
}
categories.push(secondAreas)
// Generate last group of areas
// ----------------------------
categories.push(
[
createArea({
label: 'Administrative',
children: [
createGroup({ label: 'IETF Registration' })
]
}),
createArea({
label: 'Coding',
children: [
createGroup({ label: 'Hackathon', toggledBy: ['hackathon'] }),
createGroup({ label: 'Code Sprint', toggledBy: ['tools'] })
]
}),
createArea({
label: 'Office hours',
children: firstAreasNames.map(n => createGroup({ label: `${n} Office Hours` }))
}),
createArea({
label: 'Open meeting',
children: [
createGroup({ label: 'WG Chairs Forum' }),
createGroup({ label: 'Newcomers\' Feedback Session' })
]
}),
createArea({
label: 'Plenary',
children: [
createGroup({ label: 'IETF Plenary', toggledBy: ['ietf'] })
]
}),
createArea({
label: 'Presentation',
children: [
createGroup({ label: 'Hackathon Kickoff', toggledBy: ['hackathon'] }),
createGroup({ label: 'Hackathon Project Results Presentations', toggledBy: ['hackathon'] }),
createGroup({ label: 'Host Speaker Series', toggledBy: ['ietf'] })
]
}),
createArea({
label: 'Social',
children: [
createGroup({ label: 'Newcomers\' Quick Connections' }),
createGroup({ label: 'Welcome Reception', toggledBy: ['ietf'] }),
createGroup({ label: 'Break', toggledBy: ['secretariat'] }),
createGroup({ label: 'Beverage and Snack Break', toggledBy: ['secretariat'] }),
createGroup({ label: 'Hackdemo Happy Hour', toggledBy: ['hackathon'] })
]
}),
createArea({
label: 'Tutorial',
children: [
createGroup({ label: 'Tutorial: Newcomers\' Overview' })
]
}),
createArea({
label: '',
children: [
createGroup({ label: 'BoF' }),
createGroup({ label: 'qwerty', toggledBy: ['abc'] }),
createGroup({ label: 'azerty', toggledBy: ['def'] }),
createGroup({ label: 'Tools' })
]
})
]
)
}
// Generate schedule
const schedule = []
if (!skipSchedule) {
let sessionIdx = 0
const daySessions = []
const regGroups = reverseAreaGroupsMapping([...categories[0], ...categories[1]])
// DAY 1 - No regular sessions
// ---------------------------
const day1 = startDate
schedule.push(createEvent({
name: 'Hackathon',
startDateTime: day1.set({ hour: 9, minute: 30 }),
duration: '11.5h',
...findAreaGroup('hackathon', categories[2]),
showAgenda: true,
hasAgenda: true,
hasRecordings: true,
hasVideoStream: false
}, floors))
schedule.push(createEvent({
name: 'Code Sprint',
startDateTime: day1.set({ hour: 10 }),
duration: '12h',
...findAreaGroup('code-sprint', categories[2])
}, floors))
schedule.push(createEvent({
name: 'Hackathon Kickoff',
startDateTime: day1.set({ hour: 10, minute: 30 }),
duration: '30m',
...findAreaGroup('hackathon', categories[2]),
showAgenda: true,
hasAgenda: true,
hasRecordings: true,
hasVideoStream: false
}, floors))
// DAY 2 - No regular sessions
// ---------------------------
const day2 = startDate.plus({ days: 1 })
schedule.push(createEvent({
name: 'Hackathon',
startDateTime: day2.set({ hour: 9, minute: 30 }),
duration: '6.5h',
...findAreaGroup('hackathon', categories[2]),
showAgenda: true,
hasAgenda: true,
hasVideoStream: false
}, floors))
schedule.push(createEvent({
name: 'IETF Registration',
startDateTime: day2.set({ hour: 10 }),
duration: '8h',
...findAreaGroup('ietf-registration', categories[2])
}, floors))
schedule.push(createEvent({
name: 'Tutorial: Newcomers',
startDateTime: day2.set({ hour: 12, minute: 30 }),
duration: '1h',
...findAreaGroup('tutorial-newcomers-overview', categories[2]),
showAgenda: true,
hasRecordings: true,
hasVideoStream: true
}, floors))
schedule.push(createEvent({
name: 'Hackathon Results Presentations',
startDateTime: day2.set({ hour: 14 }),
duration: '2h',
...findAreaGroup('hackathon-project-results-presentations', categories[2])
}, floors))
schedule.push(createEvent({
name: 'Newcomers\' Quick Connections (Note that pre-registration is required)',
startDateTime: day2.set({ hour: 16 }),
duration: '1h',
...findAreaGroup('newcomers-quick-connections', categories[2]),
hasLocation: false
}, floors))
schedule.push(createEvent({
name: 'ABC AD Office Hours',
startDateTime: day2.set({ hour: 16 }),
duration: '1h',
...findAreaGroup('abc-office-hours', categories[2])
}, floors))
schedule.push(createEvent({
name: 'DEF AD Office Hours',
startDateTime: day2.set({ hour: 16, minute: 15 }),
duration: '45m',
...findAreaGroup('def-office-hours', categories[2])
}, floors))
schedule.push(createEvent({
name: 'Welcome Reception',
startDateTime: day2.set({ hour: 17 }),
duration: '2h',
...findAreaGroup('welcome-reception', categories[2])
}, floors))
// DAY 3-7 - Regular Sessions
// --------------------------
for (let dayIdx = 2; dayIdx < 7; dayIdx++) {
const curDay = startDate.plus({ days: dayIdx })
daySessions.push(...sampleSize(regGroups, 24))
schedule.push(createEvent({
name: 'Continental Breakfast',
startDateTime: curDay.set({ hour: 8, minute: 30 }),
duration: '1.5h',
type: 'break',
...findAreaGroup('beverage-and-snack-break', categories[2])
}, floors))
schedule.push(createEvent({
name: 'ABC AD Office Hours',
startDateTime: curDay.set({ hour: 8, minute: 30 }),
duration: '8.5h',
...findAreaGroup('abc-office-hours', categories[2])
}, floors))
schedule.push(createEvent({
name: 'IETF Registration',
startDateTime: curDay.set({ hour: 8, minute: 30 }),
duration: '8h',
...findAreaGroup('ietf-registration', categories[2])
}, floors))
schedule.push(createEvent({
name: 'DEF AD Office Hours',
startDateTime: curDay.set({ hour: 9 }),
duration: '8.5h',
...findAreaGroup('def-office-hours', categories[2])
}, floors))
schedule.push(createEvent({
name: 'GHI AD Office Hours',
startDateTime: curDay.set({ hour: 9 }),
duration: '30m',
...findAreaGroup('ghi-office-hours', categories[2]),
hasLocation: false
}, floors))
// -> Session I
_.times(8, () => { // 8 lanes per session time
const { area, ...group } = daySessions.pop()
schedule.push(createEvent({
slotName: 'Session I',
startDateTime: curDay.set({ hour: 10 }),
duration: '2h',
type: 'regular',
group,
area,
status: getEventStatus(sessionIdx),
hasNote: sessionsWithNotes.includes(sessionIdx),
isBoF: group.is_bof,
showAgenda: true,
hasAgenda: !sessionsMissingAgenda.includes(sessionIdx),
hasRecordings: !sessionsMissingAgenda.includes(sessionIdx),
hasWebex: sessionsWithWebex.includes(sessionIdx)
}, floors))
sessionIdx++
})
schedule.push(createEvent({
name: 'Break',
startDateTime: curDay.set({ hour: 12 }),
duration: '1.5h',
type: 'break',
...findAreaGroup('beverage-and-snack-break', categories[2])
}, floors))
// -> Session II
_.times(8, () => { // 8 lanes per session time
const { area, ...group } = daySessions.pop()
schedule.push(createEvent({
slotName: 'Session II',
startDateTime: curDay.set({ hour: 13, minute: 30 }),
duration: '1h',
type: 'regular',
group,
area,
status: getEventStatus(sessionIdx),
hasNote: sessionsWithNotes.includes(sessionIdx),
isBoF: group.is_bof,
showAgenda: true,
hasAgenda: !sessionsMissingAgenda.includes(sessionIdx),
hasRecordings: !sessionsMissingAgenda.includes(sessionIdx),
hasWebex: sessionsWithWebex.includes(sessionIdx)
}, floors))
sessionIdx++
})
// -> No 3rd session on last day
if (dayIdx < 6) {
schedule.push(createEvent({
name: 'Beverage and Snack Break',
startDateTime: curDay.set({ hour: 14, minute: 30 }),
duration: '30m',
type: 'break',
...findAreaGroup('beverage-and-snack-break', categories[2])
}, floors))
// -> Session III
_.times(8, () => { // 8 lanes per session time
const { area, ...group } = daySessions.pop()
schedule.push(createEvent({
slotName: 'Session III',
startDateTime: curDay.set({ hour: 15 }),
duration: '2h',
type: 'regular',
group,
area,
status: getEventStatus(sessionIdx),
hasNote: sessionsWithNotes.includes(sessionIdx),
isBoF: group.is_bof,
showAgenda: true,
hasAgenda: !sessionsMissingAgenda.includes(sessionIdx),
hasRecordings: !sessionsMissingAgenda.includes(sessionIdx),
hasWebex: sessionsWithWebex.includes(sessionIdx)
}, floors))
sessionIdx++
})
}
// -> Plenary
if (dayIdx === 4) {
schedule.push(createEvent({
name: 'Beverage and Snack Break',
startDateTime: curDay.set({ hour: 17 }),
duration: '30m',
type: 'break',
...findAreaGroup('beverage-and-snack-break', categories[2])
}, floors))
schedule.push(createEvent({
name: 'IETF Plenary',
startDateTime: curDay.set({ hour: 17, minute: 30 }),
duration: '2h',
type: 'plenary',
showAgenda: true,
hasAgenda: true,
hasRecordings: true,
...findAreaGroup('ietf-plenary', categories[2])
}, floors))
}
}
}
// Return response object
return {
meeting: {
number: '123',
city: faker.location.city(),
startDate: startDate.toISODate(),
endDate: endDate.toISODate(),
updated: faker.date.between({ from: startDate.toISO(), to: endDate.toISO() }).toISOString(),
timezone: 'Asia/Tokyo',
infoNote: faker.lorem.paragraph(4),
warningNote: ''
},
categories,
isCurrentMeeting: dateMode !== 'past',
usesNotes: true,
schedule,
floors
}
},
/**
* Format URL by replacing inline variables
*
* @param {String} url Raw URL
* @param {Object} session Session Object
* @param {String} meetingNumber Meeting Number
* @returns Formatted URL
*/
formatLinkUrl: (url, session, meetingNumber) => {
return url
? url.replace('{meeting.number}', meetingNumber)
.replace('{group.acronym}', session.groupAcronym)
.replace('{short}', session.short)
.replace('{order_number}', session.orderInMeeting)
: url
},
/**
* Find the first URL in text matching a conference domain
*
* @param {String} txt Raw Text
* @returns First URL found
*/
findFirstConferenceUrl: (txt) => {
try {
const fUrl = txt.match(urlRe)
if (fUrl && fUrl[0].length > 0) {
const pUrl = new URL(fUrl[0])
if (conferenceDomains.some(d => pUrl.hostname.endsWith(d))) {
return fUrl[0]
}
}
} catch (err) { }
return null
}
}