-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Club revenue #1427
base: dev
Are you sure you want to change the base?
Club revenue #1427
Conversation
@evanugarte date formats have been corrected |
api/main_endpoints/routes/User.js
Outdated
|
||
const today = new Date(); | ||
|
||
let count, newSingleSemester, newAnnualMembers, totalNewMembersThisYear, currentActiveMembers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialize these when you assign them, and use const
api/main_endpoints/routes/User.js
Outdated
const currentYear = new Date().getFullYear(); | ||
|
||
const today = new Date(); | ||
const jan1ThisYear = new Date(currentYear, 0, 1); | ||
const june1ThisYear = new Date(currentYear, 5, 1); | ||
const jan1NextYear = new Date(currentYear + 1, 0, 1); | ||
const june1NextYear = new Date(currentYear + 1, 5, 1); | ||
const dec31ThisYear = new Date(currentYear, 11, 31); | ||
|
||
const totalNewMembersThisYear = await User.countDocuments({ emailVerified: true, accessLevel: membershipState.MEMBER, joinDate: { $gte: jan1ThisYear, $lte: today } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic is pretty tough to follow, can we do something like this
# find out what part of the year "now" is
beginningOfSemester = # set to beginning of current semester
endOfThisSemester = # set to beginning of current semester
endOfNextSemester = # set to beginning of current semester
numberOfNewSemesterMemberships = # query the number of members who's accounts were created after beginningOfSemester, and expiration is endOfThisSemester
numberOfNewAnnualMemberships = # query the number of members who's accounts were created after beginningOfSemester, and expiration is endOfNextSemester
# take numberOfNewSemesterMemberships and numberOfNewAnnualMemberships and return that to the frontend as json
api/main_endpoints/routes/User.js
Outdated
} else { | ||
beginningOfSemester = new Date(currentYear, 5, 1); | ||
endOfThisSemester = new Date(currentYear + 1, 0, 1); | ||
endOfNextSemester = new Date(currentYear + 1, 5, 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the initial values of the variables these, put it above the if statement, no need for else
@@ -509,4 +509,41 @@ router.post('/usersSubscribedAndVerified', function(req, res) { | |||
}); | |||
}); | |||
|
|||
// For Club Revenue page | |||
router.post('/countMembers', async (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wanna try adding a unit test for this? see
Line 135 in 1ab954d
const result = await test.sendPostRequestWithToken( |
Issuse #1414