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

Send email notifications for campaign milestones ONLY once #538

Open
slavcho opened this issue Aug 17, 2023 · 1 comment
Open

Send email notifications for campaign milestones ONLY once #538

slavcho opened this issue Aug 17, 2023 · 1 comment
Labels
type: bug Something isn't working

Comments

@slavcho
Copy link
Contributor

slavcho commented Aug 17, 2023

Which area(s) of Podkrepi.bg are affected? (leave empty if unsure)

No response

Describe the Bug

Currently if too many donations come very fast, due to the lack of safe synchronization, we will send multiple email notifications.
We rely on the database to check if such a notification was already sent.

We don't have that many donations at the moment, but still.
This can become potentially a problem in the light of the automated b2b donations.
There we can expect that many small donations will arrive very often.

My best guess here is that we need to use the PostgreSQL transactions for that. And raise an event only if it was the current donation that moved the needle above the threshold.

To Reproduce

I assume we can reproduce this even with a unit test.

Expected Behavior

Should send only 1 notification when the raised amount goes above the thresholds (of 50%, 90%, or 100%)

Which browser are you using? (if relevant)

No response

@slavcho slavcho added the type: bug Something isn't working label Aug 17, 2023
@slavcho slavcho changed the title File email notifications for campaign milestones ONLY once Send email notifications for campaign milestones ONLY once Aug 17, 2023
@igoychev
Copy link
Contributor

FYI it looks like NestJS has integrated a message queue that helps for jobs in a multi-node environment:
https://docs.nestjs.com/techniques/queues
it has some capabilities of running a duplicated job only once as per this guide:
https://docs.bullmq.io/guide/jobs/repeatable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants