Skip to content
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

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

Club revenue #1427

wants to merge 15 commits into from

Conversation

cruiserkasuga
Copy link
Collaborator

Issuse #1414

@cruiserkasuga cruiserkasuga linked an issue Jun 13, 2024 that may be closed by this pull request
5 tasks
@cruiserkasuga
Copy link
Collaborator Author

@evanugarte date formats have been corrected


const today = new Date();

let count, newSingleSemester, newAnnualMembers, totalNewMembersThisYear, currentActiveMembers;
Copy link
Collaborator

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

Comment on lines 520 to 529
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 } });
Copy link
Collaborator

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

Comment on lines 529 to 533
} else {
beginningOfSemester = new Date(currentYear, 5, 1);
endOfThisSemester = new Date(currentYear + 1, 0, 1);
endOfNextSemester = new Date(currentYear + 1, 5, 1);
}
Copy link
Collaborator

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) => {
Copy link
Collaborator

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

const result = await test.sendPostRequestWithToken(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show club revenue from membership fees for each semester
2 participants