-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparticipants.js
380 lines (315 loc) · 9.23 KB
/
participants.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
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
var XLSX = require('xlsx')
var _ = require('lodash')
var moment = require('moment')
var IMAGES = {
'Attendee': 'images/badge-print.png',
'Trainee': 'images/badge-print.png',
'Speaker': 'images/badge-print2.png',
'Organizer': 'images/badge-print3.png',
'Sponsor': 'images/badge-print4.png'
}
var DIET_STOP_LIST = [
'meat, shrimps',
'Food',
'Steak, burgers or pizzas',
'None, I'm happy with anyting',
'Nope',
'nope',
'sushi',
'No preferences',
'No.',
'cheeseburger :)',
'Meat! :o)',
'Nope',
'I love meat.',
'I like food',
'no, thanks',
'No',
'no',
'Beef',
'Steak, Burgers or pizzas.',
'Chicken',
'Roast beef',
'None, I'm happy with anyting',
'Steak & Salad',
'sushi',
'No preferences',
'NA',
'Meet',
'Meat',
'Nope.',
'I love meat.',
'Sushi!',
'banana',
'Burger',
'all its fine',
'None',
'none',
'T',
'no :)',
'No restrictions'
]
var TSHIRTS = {
'Female XS': 0,
'Female S': 0,
'Female M': 0,
'Female L': 0,
'Female XL': 0,
'Female XXL': 0,
'Male XS': 0,
'Male S': 0,
'Male M': 0,
'Male L': 0,
'Male XL': 0,
'Male XXL': 0,
'-': 0,
'number': 0
}
var TICKET_TYPES = {
'numberRegular': 0,
'numberDiscounted': 0,
'numberFree': 0,
'total': 0,
'number': 0
}
var STATS = {
'conf': {
'tickets': {
'blindBird': Object.assign({}, TICKET_TYPES),
'earlyBird': Object.assign({}, TICKET_TYPES),
'lateBird': Object.assign({}, TICKET_TYPES),
'studentPass': Object.assign({}, TICKET_TYPES),
'total': 0,
'number': 0
},
'people': {
'attendees': 0,
'organizers': 0,
'speakers': 0,
'sponsors': 0,
'number': 0
},
'diet': {
'list': [],
'number': 0
},
'referrer': {
"I'm Mobile Era 2016 participant": 0,
'Twitter': 0,
'Facebook': 0,
'Meetup': 0,
'Search engine': 0,
'Printed ad': 0,
'Article or blog post': 0,
'Friend': 0
}
},
'workshops': {
'tickets': {
'WORKSHOP: Kotlin for Java developers': {
'total': 0,
'number': 0
},
'WORKSHOP: Building Cross Platform Native Mobile Apps using React Native': {
'total': 0,
'number': 0
},
'WORKSHOP: Reactive Programming with RxSwift': {
'total': 0,
'number': 0
},
'WORKSHOP: Continuous Deployment: Automate your app release process with fastlane': {
'total': 0,
'number': 0
},
'total': 0,
'number': 0
},
'people': {
'attendees': 0,
'organizers': 0,
'speakers': 0,
'sponsors': 0,
'number': 0
},
'diet': {
'list': [],
'number': 0
}
},
'tshirts': {
'attendees': Object.assign({}, TSHIRTS),
'organizers': Object.assign({}, TSHIRTS),
'speakers': Object.assign({}, TSHIRTS),
'sponsors': Object.assign({}, TSHIRTS),
'black': Object.assign({}, TSHIRTS),
'white': Object.assign({}, TSHIRTS),
'number': 0
},
'total': 0,
'filteredByDate': 0
}
function createParticipant (participant) {
var firstName = participant['Ticket First Name'] || ''
var lastName = participant['Ticket Last Name'] || ''
var fullName = firstName.trim() + ' ' + lastName.trim()
var company = participant['Ticket Company Name']
var sessionInfo = null
var ticketName = participant['Ticket']
var ticketPrice = parseInt(participant['Price'])
var categoryName = null
var tShirt = participant['T-shirt type & size']
var dietAnswer = participant['Do you have any dietary restrictions?'].trim()
var diet = (dietAnswer === '-' || _.includes(DIET_STOP_LIST, dietAnswer)) ? null : dietAnswer
var discount = participant['Order Discount Code'] !== '-' ? participant['Order Discount Code'] : null
var referrer = participant['How did you hear about us?'] !== '-' ? participant['How did you hear about us?'] : null
var email = participant['Ticket Email']
var contactCard = fullName + ' <' + email + '>'
var modifiedDate = moment(participant['Ticket Last Updated Date'], 'MM/DD/YY'); // Last Updated | Created
var twitter = participant['Twitter handle to print on your badge'] !== '-' ? '@' + _.trimStart(participant['Twitter handle to print on your badge'], '@') : null
if (company) {
contactCard += ' of ' + company
}
if (ticketName.includes('Bird') || ticketName.includes('Student') || ticketName.includes('Discounted') ) {
categoryName = 'Attendee'
var confType = _.camelCase(ticketName)
if (confType == 'sponsorBlindBirdInvoiced') {
confType = 'blindBird'
discount = 'sponsorBlindBirdInvoiced'
}
if (confType == 'speakerDiscountedTicket') {
confType = 'blindBird'
discount = 'speakerDiscountedTicket'
}
STATS.conf.tickets.number++
STATS.conf.tickets.total += ticketPrice
STATS.conf.people.attendees++
STATS.conf.people.number++
STATS.total += ticketPrice
if (ticketPrice === 0) {
STATS.conf.tickets[confType].numberFree++
STATS.conf.tickets[confType].number++
console.log('Free ticket with code/tag: ' + ( discount ? discount : '' ) + ( participant['Tags'] ? participant['Tags'] : '' ) + ' ref: ' + participant['Ticket Reference'] + ' company: ' + participant['Ticket Company Name'])
} else if (!discount) {
STATS.conf.tickets[confType].numberRegular++
STATS.conf.tickets[confType].number++
STATS.conf.tickets[confType].total += ticketPrice
} else {
STATS.conf.tickets[confType].numberDiscounted++
STATS.conf.tickets[confType].number++
STATS.conf.tickets[confType].total += ticketPrice
// console.log('Discounted ticket with code: ' + participant['Order Discount Code'] + ' and price ' + ticketPrice + ' ref: ' + participant['Ticket Reference'])
}
STATS.tshirts.attendees[tShirt]++
STATS.tshirts.attendees.number++
STATS.tshirts.number++
STATS.tshirts.black[tShirt]++
STATS.tshirts.black.number++
if (diet) {
STATS.conf.diet.list.push(diet)
STATS.conf.diet.number++
}
if (referrer && (STATS.conf.referrer[referrer] === 0 || STATS.conf.referrer[referrer] > 0)) {
STATS.conf.referrer[referrer]++
}
} else if (ticketName.includes('WORKSHOP')) {
categoryName = 'Trainee'
STATS.workshops.tickets.number++
STATS.workshops.tickets.total += ticketPrice
STATS.workshops.people.attendees++
STATS.workshops.people.number++
STATS.total += ticketPrice
STATS.workshops.tickets[ticketName].number++
STATS.workshops.tickets[ticketName].total += ticketPrice
if (diet) {
STATS.workshops.diet.list.push(diet)
STATS.workshops.diet.number++
}
} else if (ticketName === 'Crew ticket') {
categoryName = participant['Crew type']
STATS.conf.people.organizers++
STATS.conf.people.number++
STATS.tshirts.organizers[tShirt]++
STATS.tshirts.organizers.number++
STATS.tshirts.number++
STATS.tshirts.white[tShirt]++
STATS.tshirts.white.number++
if (diet) {
STATS.conf.diet.list.push(diet)
STATS.conf.diet.number++
}
} else if (ticketName === 'Speaker Ticket') {
categoryName = 'Speaker'
sessionInfo = participant['Session']
STATS.conf.people.speakers++
STATS.conf.people.number++
STATS.tshirts.speakers[tShirt]++
STATS.tshirts.speakers.number++
STATS.tshirts.number++
STATS.tshirts.black[tShirt]++
STATS.tshirts.black.number++
if (diet) {
STATS.conf.diet.list.push(diet)
STATS.conf.diet.number++
}
} else if (ticketName.includes('Sponsor')) {
categoryName = 'Sponsor'
STATS.conf.people.sponsors++
STATS.conf.people.number++
STATS.tshirts.sponsors[tShirt]++
STATS.tshirts.sponsors.number++
STATS.tshirts.number++
STATS.tshirts.black[tShirt]++
STATS.tshirts.black.number++
if (diet) {
STATS.conf.diet.list.push(diet)
STATS.conf.diet.number++
}
} else {
console.log('===== Unknown category for ticket ' + participant['Ticket'])
}
var image = IMAGES[categoryName]
return {
fullName,
company,
contactCard,
sessionInfo,
image,
categoryName,
ticketName,
modifiedDate,
twitter
}
}
function participants (filename, filterOnType, startingDate) {
var workbook = XLSX.readFile(filename)
var worksheet = workbook.Sheets[workbook.SheetNames[0]]
var participantsRaw = XLSX.utils.sheet_to_json(worksheet)
var participantsProcessed = participantsRaw.map(function (participant) {
return createParticipant(participant)
}).filter(function (p) {
return p.categoryName
}).filter(function (p) {
return !filterOnType || filterOnType === p.categoryName
}).filter(function (p) {
if (startingDate) {
if (p.modifiedDate.isSameOrAfter(startingDate)) {
console.log('Modified date: ' + p.modifiedDate.format())
STATS.filteredByDate++
return true
} else {
return true // hack
}
} else {
return true
}
}).sort(function (a, b) {
if (a.categoryName.localeCompare(b.categoryName) != 0) {
return a.categoryName.localeCompare(b.categoryName)
}
return a.fullName.localeCompare(b.fullName)
})
console.log(JSON.stringify(STATS, undefined, 2))
return participantsProcessed
}
module.exports = participants