Skip to content

Commit

Permalink
update find member by email
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou committed Mar 29, 2024
1 parent cd8b267 commit 5303edd
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/core/src/admin-dashboard.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export { createEvent } from './modules/event/use-cases/create-event';
export { archiveActivity } from './modules/gamification/use-cases/archive-activity';
export { editActivity } from './modules/gamification/use-cases/edit-activity';
export { addIcebreakerPrompt } from './modules/icebreaker/use-cases/add-icebreaker-prompt';
export { findMemberByEmail } from './modules/member/queries/find-member-by-email';
export { activateMember } from './modules/member/use-cases/activate-member';
export { updateMemberEmail } from './modules/member/use-cases/update-member-email';
export { addOnboardingSessionAttendees } from './modules/onboarding-session/use-cases/add-onboarding-session-attendees';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function loginWithOAuth(input: OAuthLoginInput) {
.where('deletedAt', 'is', null)
.executeTakeFirst();
} else {
entity = await findMemberByEmail(email).select(['id']).executeTakeFirst();
entity = await findMemberByEmail(email);
}

if (!entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export async function syncAirmeetEvent({

await Promise.all(
attendees.map(async (attendee) => {
const student = await findMemberByEmail(attendee.email)
.select(['students.id'])
.executeTakeFirst();
const student = await findMemberByEmail(attendee.email);

await trx
.insertInto('eventAttendees')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,15 @@ async function getActivityData(campaignId: string) {
// we can find them.

for (const click of result.clicks) {
const student = await findMemberByEmail(click.email)
.select(['id'])
.executeTakeFirst();
const student = await findMemberByEmail(click.email);

if (student) {
click.studentId = student.id;
}
}

for (const open of result.opens) {
const student = await findMemberByEmail(open.email)
.select(['id'])
.executeTakeFirst();
const student = await findMemberByEmail(open.email);

if (student) {
open.studentId = student.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ export function findMemberByEmail(email: string) {
return db
.selectFrom('students')
.leftJoin('studentEmails', 'studentEmails.studentId', 'students.id')
.where('studentEmails.email', 'ilike', email);
.select(['students.id'])
.where('studentEmails.email', 'ilike', email)
.executeTakeFirst();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ export async function onSlackWorkspaceJoined({
email,
slackId,
}: GetBullJobData<'slack.joined'>) {
const member = await findMemberByEmail(email)
.select(['id'])
.executeTakeFirst();
const member = await findMemberByEmail(email);

if (!member) {
throw new NotFoundError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export async function importSurveyResponses(
'Responded On': respondedOn,
} = result.data;

const student = await findMemberByEmail(email)
.select(['students.id'])
.executeTakeFirst();
const student = await findMemberByEmail(email);

return SurveyResponse.pick({
email: true,
Expand Down

0 comments on commit 5303edd

Please sign in to comment.