Skip to content

Commit

Permalink
Added country of residence field to hacker application
Browse files Browse the repository at this point in the history
  • Loading branch information
allennatang authored and tektaxi committed Nov 15, 2024
1 parent f711c42 commit 5b6abd6
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 5 deletions.
5 changes: 5 additions & 0 deletions middlewares/validators/hacker.validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ module.exports = {
"application.other.ethnicity",
false
),
VALIDATOR.stringValidator(
"body",
"application.other.country",
false
),
VALIDATOR.booleanValidator(
"body",
"application.other.privacyPolicy",
Expand Down
5 changes: 5 additions & 0 deletions middlewares/validators/validator.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
shirtSize: false,
other: false,
ethnicity: false,
country: false,
codeOfConduct: false,
privacyPolicy: false
};
Expand Down Expand Up @@ -439,6 +440,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.other = app.hasOwnProperty("other");
if (hasValid.other) {
hasValid.ethnicity = app.other.hasOwnProperty("ethnicity");
hasValid.country = app.other.hasOwnProperty("country");
hasValid.codeOfConduct = app.other.hasOwnProperty(
"codeOfConduct"
);
Expand Down Expand Up @@ -497,6 +499,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.shirtSize &&
hasValid.other &&
hasValid.ethnicity &&
hasValid.country &&
hasValid.privacyPolicy &&
hasValid.codeOfConduct
);
Expand Down Expand Up @@ -545,6 +548,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.other = app.hasOwnProperty("other");
if (hasValid.other) {
hasValid.ethnicity = app.other.hasOwnProperty("ethnicity");
hasValid.country = app.other.hasOwnProperty("country");
hasValid.codeOfConduct = app.other.hasOwnProperty(
"codeOfConduct"
);
Expand Down Expand Up @@ -603,6 +607,7 @@ function applicationValidator(fieldLocation, fieldname, optional = true) {
hasValid.shirtSize &&
hasValid.other &&
hasValid.ethnicity &&
hasValid.country &&
hasValid.privacyPolicy &&
hasValid.codeOfConduct
);
Expand Down
4 changes: 4 additions & 0 deletions models/hacker.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const HackerSchema = new mongoose.Schema({
],
required: true
},
country: {
type: String,
required: true
},
privacyPolicy: {
type: Boolean,
required: true
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
"start": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
"start-windows": "set DEBUG=hackboard:* && set NODE_ENV=test && nodemon --ignore gcp_creds.json ./bin/www.js",
"deploy": "NODE_ENV=deployment node ./bin/www.js",
"debug": "DEBUG=hackboard:* NODE_ENV=test nodemon --ignore gcp_creds.json ./bin/www.js",
"test": "DEBUG=hackboard:* NODE_ENV=test mocha -r dotenv/config --reporter spec tests/**.js --exit",
"test-windows": "DEBUG=hackboard:* SET NODE_ENV=test & mocha -r dotenv/config --reporter spec tests/**.js --exit",
"seed": "NODE_ENV=test node ./seed/index.js",
"seed-windows": "SET NODE_ENV=test & node ./seed/index.js",
"debug": "DEBUG=hackboard:* NODE_ENV=development nodemon --ignore gcp_creds.json ./bin/www.js",
"test": "DEBUG=hackboard:* NODE_ENV=development mocha -r dotenv/config --reporter spec tests/**.js --exit",
"test-windows": "DEBUG=hackboard:* SET NODE_ENV=development & mocha -r dotenv/config --reporter spec tests/**.js --exit",
"seed": "NODE_ENV=development node ./seed/index.js",
"docs": "apidoc -i ./routes -o ./docs/api/",
"format": "prettier --write '**/*.js'",
"lint": "eslint --fix '**/*.js'"
Expand Down
Binary file added results.txt
Binary file not shown.
Binary file added results2.txt
Binary file not shown.
10 changes: 10 additions & 0 deletions routes/api/hacker.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
},
"status":"Applied",
"ethnicity":["White or Caucasian"," Asian or Pacific Islander"],
"country":"Canada",
"accountId":"5bff2a35e533b0f6562b4998",
"school":"McPherson College",
"gender":"Female",
Expand Down Expand Up @@ -90,6 +91,7 @@ module.exports = {
* @apiParam (body) {String} gender Gender of the hacker
* @apiParam (body) {Number} travel Whether the hacker requires a bus for transportation
* @apiParam (body) {String[]} ethnicity the ethnicities of the hacker
* @apiParam (body) {String} country Name of the country of residence of the hacker
* @apiParam (body) {String[]} major the major of the hacker
* @apiParam (body) {Number} graduationYear the graduation year of the hacker
* @apiParam (body) {Boolean} codeOfConduct acceptance of the code of conduct
Expand Down Expand Up @@ -122,6 +124,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down Expand Up @@ -170,6 +173,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down Expand Up @@ -235,6 +239,7 @@ module.exports = {
gender: { "Male": 1, "Female": 9 },
travel: { "true": 7, "false": 3 },
ethnicity: { "White": 10, },
country: {"Canada": 10},
jobInterest: { "Internship": 10 },
major: { "Computer Science": 10 },
graduationYear: { "2019": 10 },
Expand Down Expand Up @@ -435,6 +440,7 @@ module.exports = {
* @apiParam (body) {String} [gender] Gender of the hacker
* @apiParam (body) {Number} [travel] How much the hacker requires a bus for transportation
* @apiParam (body) {String[]} [ethnicity] the ethnicities of the hacker
* @apiParam (body) {String} [country] Country of residence of the hacker
* @apiParam (body) {String[]} [major] the major of the hacker
* @apiParam (body) {Number} [graduationYear] the graduation year of the hacker
* @apiParam (body) {Json} [application] The hacker's application
Expand Down Expand Up @@ -466,6 +472,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down Expand Up @@ -514,6 +521,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down Expand Up @@ -591,6 +599,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down Expand Up @@ -664,6 +673,7 @@ module.exports = {
"other:" {
"gender": "male",
"ethnicity": "Asian or Pacific Islander",
"country": "Canada",
"privacyPolicy": true,
"codeOfConduct": true,
}
Expand Down
7 changes: 7 additions & 0 deletions services/hacker.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function getStats(hackers) {
gender: {},
travel: {},
ethnicity: {},
country: {},
jobInterest: {},
fieldOfStudy: {},
graduationYear: {},
Expand Down Expand Up @@ -177,6 +178,12 @@ function getStats(hackers) {
: 1;
}

stats.country[hacker.application.other.country] = stats.country[
hacker.application.other.country
]
? stats.country[hacker.application.other.country] + 1
: 1;

stats.jobInterest[hacker.application.general.jobInterest] = stats
.jobInterest[hacker.application.general.jobInterest]
? stats.jobInterest[hacker.application.general.jobInterest] + 1
Expand Down
1 change: 1 addition & 0 deletions tests/hacker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ describe("GET Hacker stats", function() {
res.body.data.stats.should.have.property("gender");
res.body.data.stats.should.have.property("travel");
res.body.data.stats.should.have.property("ethnicity");
res.body.data.stats.should.have.property("country");
res.body.data.stats.should.have.property("jobInterest");
res.body.data.stats.should.have.property("fieldOfStudy");
res.body.data.stats.should.have.property("graduationYear");
Expand Down
16 changes: 16 additions & 0 deletions tests/util/hacker.test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const TeamHacker0 = {
},
other: {
ethnicity: ["Native American"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -81,6 +82,7 @@ const TeamHacker1 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -123,6 +125,7 @@ const TeamHacker2 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -165,6 +168,7 @@ const TeamHacker3 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -207,6 +211,7 @@ const TeamHacker4 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -249,6 +254,7 @@ const NoTeamHacker0 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -288,6 +294,7 @@ const newHacker0 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -327,6 +334,7 @@ const newHacker1 = {
},
other: {
ethnicity: ["African American"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -367,6 +375,7 @@ const invalidHacker0 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
// must accept code of conduct to be valid
codeOfConduct: false,
privacyPolicy: false
Expand Down Expand Up @@ -404,6 +413,7 @@ const invalidHacker1 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -446,6 +456,7 @@ const invalidHacker2 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -487,6 +498,7 @@ const invalidHacker3 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -529,6 +541,7 @@ const duplicateAccountLinkHacker0 = {
},
other: {
ethnicity: ["Caucasian"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -570,6 +583,7 @@ const waitlistedHacker0 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -612,6 +626,7 @@ const unconfirmedAccountHacker0 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down Expand Up @@ -653,6 +668,7 @@ const unconfirmedAccountHacker1 = {
},
other: {
ethnicity: ["European"],
country: "Canada",
codeOfConduct: true,
privacyPolicy: true
},
Expand Down

0 comments on commit 5b6abd6

Please sign in to comment.