Skip to content

Commit 5b6abd6

Browse files
allennatangtektaxi
authored andcommitted
Added country of residence field to hacker application
1 parent f711c42 commit 5b6abd6

File tree

10 files changed

+52
-5
lines changed

10 files changed

+52
-5
lines changed

middlewares/validators/hacker.validator.js

+5
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ module.exports = {
251251
"application.other.ethnicity",
252252
false
253253
),
254+
VALIDATOR.stringValidator(
255+
"body",
256+
"application.other.country",
257+
false
258+
),
254259
VALIDATOR.booleanValidator(
255260
"body",
256261
"application.other.privacyPolicy",

middlewares/validators/validator.helper.js

+5
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
392392
shirtSize: false,
393393
other: false,
394394
ethnicity: false,
395+
country: false,
395396
codeOfConduct: false,
396397
privacyPolicy: false
397398
};
@@ -439,6 +440,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
439440
hasValid.other = app.hasOwnProperty("other");
440441
if (hasValid.other) {
441442
hasValid.ethnicity = app.other.hasOwnProperty("ethnicity");
443+
hasValid.country = app.other.hasOwnProperty("country");
442444
hasValid.codeOfConduct = app.other.hasOwnProperty(
443445
"codeOfConduct"
444446
);
@@ -497,6 +499,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
497499
hasValid.shirtSize &&
498500
hasValid.other &&
499501
hasValid.ethnicity &&
502+
hasValid.country &&
500503
hasValid.privacyPolicy &&
501504
hasValid.codeOfConduct
502505
);
@@ -545,6 +548,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
545548
hasValid.other = app.hasOwnProperty("other");
546549
if (hasValid.other) {
547550
hasValid.ethnicity = app.other.hasOwnProperty("ethnicity");
551+
hasValid.country = app.other.hasOwnProperty("country");
548552
hasValid.codeOfConduct = app.other.hasOwnProperty(
549553
"codeOfConduct"
550554
);
@@ -603,6 +607,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
603607
hasValid.shirtSize &&
604608
hasValid.other &&
605609
hasValid.ethnicity &&
610+
hasValid.country &&
606611
hasValid.privacyPolicy &&
607612
hasValid.codeOfConduct
608613
);

models/hacker.model.js

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ const HackerSchema = new mongoose.Schema({
103103
],
104104
required: true
105105
},
106+
country: {
107+
type: String,
108+
required: true
109+
},
106110
privacyPolicy: {
107111
type: Boolean,
108112
required: true

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
"start": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
77
"start-windows": "set DEBUG=hackboard:* && set NODE_ENV=test && nodemon --ignore gcp_creds.json ./bin/www.js",
88
"deploy": "NODE_ENV=deployment node ./bin/www.js",
9-
"debug": "DEBUG=hackboard:* NODE_ENV=test nodemon --ignore gcp_creds.json ./bin/www.js",
10-
"test": "DEBUG=hackboard:* NODE_ENV=test mocha -r dotenv/config --reporter spec tests/**.js --exit",
11-
"test-windows": "DEBUG=hackboard:* SET NODE_ENV=test & mocha -r dotenv/config --reporter spec tests/**.js --exit",
12-
"seed": "NODE_ENV=test node ./seed/index.js",
13-
"seed-windows": "SET NODE_ENV=test & node ./seed/index.js",
9+
"debug": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
10+
"test": "DEBUG=hackboard:* NODE_ENV=development mocha -r dotenv/config --reporter spec tests/**.js --exit",
11+
"test-windows": "DEBUG=hackboard:* SET NODE_ENV=development & mocha -r dotenv/config --reporter spec tests/**.js --exit",
12+
"seed": "NODE_ENV=development node ./seed/index.js",
1413
"docs": "apidoc -i ./routes -o ./docs/api/",
1514
"format": "prettier --write '**/*.js'",
1615
"lint": "eslint --fix '**/*.js'"

results.txt

265 KB
Binary file not shown.

results2.txt

282 KB
Binary file not shown.

routes/api/hacker.js

+10
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
},
5757
"status":"Applied",
5858
"ethnicity":["White or Caucasian"," Asian or Pacific Islander"],
59+
"country":"Canada",
5960
"accountId":"5bff2a35e533b0f6562b4998",
6061
"school":"McPherson College",
6162
"gender":"Female",
@@ -90,6 +91,7 @@ module.exports = {
9091
* @apiParam (body) {String} gender Gender of the hacker
9192
* @apiParam (body) {Number} travel Whether the hacker requires a bus for transportation
9293
* @apiParam (body) {String[]} ethnicity the ethnicities of the hacker
94+
* @apiParam (body) {String} country Name of the country of residence of the hacker
9395
* @apiParam (body) {String[]} major the major of the hacker
9496
* @apiParam (body) {Number} graduationYear the graduation year of the hacker
9597
* @apiParam (body) {Boolean} codeOfConduct acceptance of the code of conduct
@@ -122,6 +124,7 @@ module.exports = {
122124
"other:" {
123125
"gender": "male",
124126
"ethnicity": "Asian or Pacific Islander",
127+
"country": "Canada",
125128
"privacyPolicy": true,
126129
"codeOfConduct": true,
127130
}
@@ -170,6 +173,7 @@ module.exports = {
170173
"other:" {
171174
"gender": "male",
172175
"ethnicity": "Asian or Pacific Islander",
176+
"country": "Canada",
173177
"privacyPolicy": true,
174178
"codeOfConduct": true,
175179
}
@@ -235,6 +239,7 @@ module.exports = {
235239
gender: { "Male": 1, "Female": 9 },
236240
travel: { "true": 7, "false": 3 },
237241
ethnicity: { "White": 10, },
242+
country: {"Canada": 10},
238243
jobInterest: { "Internship": 10 },
239244
major: { "Computer Science": 10 },
240245
graduationYear: { "2019": 10 },
@@ -435,6 +440,7 @@ module.exports = {
435440
* @apiParam (body) {String} [gender] Gender of the hacker
436441
* @apiParam (body) {Number} [travel] How much the hacker requires a bus for transportation
437442
* @apiParam (body) {String[]} [ethnicity] the ethnicities of the hacker
443+
* @apiParam (body) {String} [country] Country of residence of the hacker
438444
* @apiParam (body) {String[]} [major] the major of the hacker
439445
* @apiParam (body) {Number} [graduationYear] the graduation year of the hacker
440446
* @apiParam (body) {Json} [application] The hacker's application
@@ -466,6 +472,7 @@ module.exports = {
466472
"other:" {
467473
"gender": "male",
468474
"ethnicity": "Asian or Pacific Islander",
475+
"country": "Canada",
469476
"privacyPolicy": true,
470477
"codeOfConduct": true,
471478
}
@@ -514,6 +521,7 @@ module.exports = {
514521
"other:" {
515522
"gender": "male",
516523
"ethnicity": "Asian or Pacific Islander",
524+
"country": "Canada",
517525
"privacyPolicy": true,
518526
"codeOfConduct": true,
519527
}
@@ -591,6 +599,7 @@ module.exports = {
591599
"other:" {
592600
"gender": "male",
593601
"ethnicity": "Asian or Pacific Islander",
602+
"country": "Canada",
594603
"privacyPolicy": true,
595604
"codeOfConduct": true,
596605
}
@@ -664,6 +673,7 @@ module.exports = {
664673
"other:" {
665674
"gender": "male",
666675
"ethnicity": "Asian or Pacific Islander",
676+
"country": "Canada",
667677
"privacyPolicy": true,
668678
"codeOfConduct": true,
669679
}

services/hacker.service.js

+7
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function getStats(hackers) {
132132
gender: {},
133133
travel: {},
134134
ethnicity: {},
135+
country: {},
135136
jobInterest: {},
136137
fieldOfStudy: {},
137138
graduationYear: {},
@@ -177,6 +178,12 @@ function getStats(hackers) {
177178
: 1;
178179
}
179180

181+
stats.country[hacker.application.other.country] = stats.country[
182+
hacker.application.other.country
183+
]
184+
? stats.country[hacker.application.other.country] + 1
185+
: 1;
186+
180187
stats.jobInterest[hacker.application.general.jobInterest] = stats
181188
.jobInterest[hacker.application.general.jobInterest]
182189
? stats.jobInterest[hacker.application.general.jobInterest] + 1

tests/hacker.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -1739,6 +1739,7 @@ describe("GET Hacker stats", function() {
17391739
res.body.data.stats.should.have.property("gender");
17401740
res.body.data.stats.should.have.property("travel");
17411741
res.body.data.stats.should.have.property("ethnicity");
1742+
res.body.data.stats.should.have.property("country");
17421743
res.body.data.stats.should.have.property("jobInterest");
17431744
res.body.data.stats.should.have.property("fieldOfStudy");
17441745
res.body.data.stats.should.have.property("graduationYear");

tests/util/hacker.test.util.js

+16
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const TeamHacker0 = {
3939
},
4040
other: {
4141
ethnicity: ["Native American"],
42+
country: "Canada",
4243
codeOfConduct: true,
4344
privacyPolicy: true
4445
},
@@ -81,6 +82,7 @@ const TeamHacker1 = {
8182
},
8283
other: {
8384
ethnicity: ["European"],
85+
country: "Canada",
8486
codeOfConduct: true,
8587
privacyPolicy: true
8688
},
@@ -123,6 +125,7 @@ const TeamHacker2 = {
123125
},
124126
other: {
125127
ethnicity: ["European"],
128+
country: "Canada",
126129
codeOfConduct: true,
127130
privacyPolicy: true
128131
},
@@ -165,6 +168,7 @@ const TeamHacker3 = {
165168
},
166169
other: {
167170
ethnicity: ["European"],
171+
country: "Canada",
168172
codeOfConduct: true,
169173
privacyPolicy: true
170174
},
@@ -207,6 +211,7 @@ const TeamHacker4 = {
207211
},
208212
other: {
209213
ethnicity: ["European"],
214+
country: "Canada",
210215
codeOfConduct: true,
211216
privacyPolicy: true
212217
},
@@ -249,6 +254,7 @@ const NoTeamHacker0 = {
249254
},
250255
other: {
251256
ethnicity: ["European"],
257+
country: "Canada",
252258
codeOfConduct: true,
253259
privacyPolicy: true
254260
},
@@ -288,6 +294,7 @@ const newHacker0 = {
288294
},
289295
other: {
290296
ethnicity: ["Caucasian"],
297+
country: "Canada",
291298
codeOfConduct: true,
292299
privacyPolicy: true
293300
},
@@ -327,6 +334,7 @@ const newHacker1 = {
327334
},
328335
other: {
329336
ethnicity: ["African American"],
337+
country: "Canada",
330338
codeOfConduct: true,
331339
privacyPolicy: true
332340
},
@@ -367,6 +375,7 @@ const invalidHacker0 = {
367375
},
368376
other: {
369377
ethnicity: ["Caucasian"],
378+
country: "Canada",
370379
// must accept code of conduct to be valid
371380
codeOfConduct: false,
372381
privacyPolicy: false
@@ -404,6 +413,7 @@ const invalidHacker1 = {
404413
},
405414
other: {
406415
ethnicity: ["Caucasian"],
416+
country: "Canada",
407417
codeOfConduct: true,
408418
privacyPolicy: true
409419
},
@@ -446,6 +456,7 @@ const invalidHacker2 = {
446456
},
447457
other: {
448458
ethnicity: ["Caucasian"],
459+
country: "Canada",
449460
codeOfConduct: true,
450461
privacyPolicy: true
451462
},
@@ -487,6 +498,7 @@ const invalidHacker3 = {
487498
},
488499
other: {
489500
ethnicity: ["Caucasian"],
501+
country: "Canada",
490502
codeOfConduct: true,
491503
privacyPolicy: true
492504
},
@@ -529,6 +541,7 @@ const duplicateAccountLinkHacker0 = {
529541
},
530542
other: {
531543
ethnicity: ["Caucasian"],
544+
country: "Canada",
532545
codeOfConduct: true,
533546
privacyPolicy: true
534547
},
@@ -570,6 +583,7 @@ const waitlistedHacker0 = {
570583
},
571584
other: {
572585
ethnicity: ["European"],
586+
country: "Canada",
573587
codeOfConduct: true,
574588
privacyPolicy: true
575589
},
@@ -612,6 +626,7 @@ const unconfirmedAccountHacker0 = {
612626
},
613627
other: {
614628
ethnicity: ["European"],
629+
country: "Canada",
615630
codeOfConduct: true,
616631
privacyPolicy: true
617632
},
@@ -653,6 +668,7 @@ const unconfirmedAccountHacker1 = {
653668
},
654669
other: {
655670
ethnicity: ["European"],
671+
country: "Canada",
656672
codeOfConduct: true,
657673
privacyPolicy: true
658674
},

0 commit comments

Comments
 (0)