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

Refactor "has active mandate" to reduce db stress #535

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

alfredgrip
Copy link
Contributor

Benchmarks show improvements by 5% 😎

While it's technically faster, it's not too much which is depressing since I thought this would be substantially faster. I guess the overhead from Prisma is what actually is costly, while the query is basically negligible. But still, I think this is good practice

Copy link
Contributor

@Macludde Macludde left a comment

Choose a reason for hiding this comment

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

LGTM

@alfredgrip alfredgrip merged commit 03561b0 into main Oct 24, 2024
4 checks passed
@alfredgrip alfredgrip deleted the active-mandate-less-data branch October 24, 2024 14:41
Comment on lines +116 to +125
prisma.mandate.findFirst({
where: {
startDate: { lte: now },
endDate: { gte: now },
memberId: locals.user?.memberId,
},
select: {
id: true,
},
}) !== null;
Copy link
Contributor

Choose a reason for hiding this comment

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

@alfredgrip Is this really correct? It looks to me like we're checking if promise !== null, since we're not awaiting the promise here but rather with Promise.allSettled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Fixed in #536

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.

3 participants