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

add documentation for memberUtils #571

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions backend/src/utils/memberUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ import { createPatch } from 'diff';
import { firestore } from 'firebase-admin';
import { archivedMembersByEmail } from '../members-archive';

/**
* Get the netID of a member from their Cornell email.
* @param email - the email of the member.
* @returns the netID of the member.
*/
export const getNetIDFromEmail = (email: string): string => email.split('@')[0];

/**
* Filters the response from Google Cloud Storage to only include the filename
* of the image.
* @param images - a list of image filenmaes and their URLs.
* @returns a list of profile images.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @returns a list of profile images.
* @returns An array containing metadata about all member profile images.

*/
Comment on lines +13 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this more descriptive of what the filename (does it contain the full path, does it contain the file extension, what file extensions are there, etc) looks like and what the purpose of the URL is.

export const filterImagesResponse = (
images: readonly { readonly fileName: string; readonly url: string }[]
): ProfileImage[] =>
Expand All @@ -15,6 +26,11 @@ export const filterImagesResponse = (
fileName: image.fileName.slice(image.fileName.indexOf('/') + 1)
}));

/**
* Serialize an `IdolMember` from a Firestore document reference.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Serialize an `IdolMember` from a Firestore document reference.
* Materialize an `IdolMember` from a Firestore document reference.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really also mention how this will lookup members from the members archive if the member isn't found in the db and will return undefined if the member doesn't exist in the db or the members archive.

* @param docRef - the Firestore document reference.
* @returns an `IdolMember` object of the member.
*/
export const getMemberFromDocumentReference = async (
docRef: firestore.DocumentReference
): Promise<IdolMember> => {
Expand All @@ -27,6 +43,14 @@ export const getMemberFromDocumentReference = async (

type SimplifiedMember = { readonly email: string };

/**
* Computes the differences between the currently approved members and the
* members who've submitted changes to their profiles.
* @param allApprovedMembersList - the list of all approved members.
* @param allLatestMembersList - the list of all members who've submitted changes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this just all the non-approved member data for all members? I.e. some members in this array could be the same as the member in the approvedMembersList?

I'd double check this docstring.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think allLatestMembersList is the list of members coming from members and allApprovedMembersList is just the list of members coming from approved-members.

* @returns a list of `IdolMemberDiff` objects that contain all the differences
* to each members' profiles.
*/
export const computeMembersDiff = <M extends SimplifiedMember>(
allApprovedMembersList: readonly M[],
allLatestMembersList: readonly M[]
Expand Down
Loading