-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
Overview
Change hacker account's birthdate field to age field. Currently, there is a function to calculate age from birthdate (updates automatically?), I will comment this out. Does changing this in hackerAPI change it in the database as well?
Same change as dashboard issue #1003
Technical details
- Change type from "String" to "Number" in
hackerAPI\docs\api\api_data.js
- Create function
ageValidator()
inhackerAPI\middlewares\validators\validator.helper.js
to validate that age is between 0 and 100 - Comment out getAge function in
hackerAPI\models\account.model.js
AccountSchema.methods.getAge = function() {
// birthday is a date
var ageDifMs = Date.now() - this.birthDate.getTime();
var ageDate = new Date(ageDifMs); // miliseconds from epoch
return Math.abs(ageDate.getUTCFullYear() - 1970);
};
used in hackerAPI\services\hacker.service.js
const age = hacker.accountId.getAge();
stats.age[age] = stats.age[age] ? stats.age[age] + 1 : 1;
Metadata
Metadata
Assignees
Labels
No labels