-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgroup.js
More file actions
48 lines (43 loc) · 1.68 KB
/
group.js
File metadata and controls
48 lines (43 loc) · 1.68 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
const activityCode = require('./activity_code')
const extension = require('./extension')
const { DateTime } = require('luxon')
class Group {
constructor(activity, room, competition) {
this.wcif = activity
this.activityCode = activityCode.parse(activity.activityCode)
this.room = room
this.startTime = DateTime.fromISO(activity.startTime).setZone(competition.schedule.venues[0].timezone)
this.endTime = DateTime.fromISO(activity.endTime).setZone(competition.schedule.venues[0].timezone)
this.stage = null
var ext = extension.getExtension(activity, 'Group')
if (ext !== null && ext.stageId !== undefined) {
var roomExt = extension.getExtension(room, 'Room')
if (roomExt !== null) {
var stage = (roomExt.stages || []).find((stage) => stage.id == ext.stageId)
if (stage !== undefined) {
this.stage = stage
}
}
}
}
name() {
if (this.activityCode.isActivity()) {
return this.wcif.name
// This is not ideal; when displaying room names we'd like to
// keep only the meaningful part (eg: "Red" when it's "Red Stage", which
// is usually the first part of the name in English, but may be some other
// parts in other languages. This is a compromise where we strip out
// 'Stage' or 'Room' suffix, which should be enough in "regular" major
// competitions setup while not messing up room names in non English setups.
// return this.room.name.replace(/Room|Stage/g, '').trim() + ' ' + this.activityCode.groupNumber
} else {
return this.activityCode.toString()
}
}
fullName() {
return this.activityCode.toString()
}
}
module.exports = {
Group: Group,
}