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

fire scenario.planningAreaProtectedCalculation.submitted much earlier [MARXAN-1316] #866

Conversation

hotzevzl
Copy link
Member

https://vizzuality.atlassian.net/browse/MARXAN-1316

We did originally fire the event changed in this PR in CalculatePlanningUnitsProtectionLevelHandler.execute(), however this would be after some potentially expensive SQL queries had been run in ScenarioPlanningUnitsProtectedStatusCalculatorService.calculatedProtectionStatusForPlanningUnitsIn(),
which would lead is some cases to a very long delay between the time an API user submits a request for POST /api/scenarios/:id/protected-areas and the time a scenario.planningAreaProtectedCalculation.submitted/v1/alpha event shows up in the scenario status data.

However, as we're moving the firing of this event across a couple of cqrs event boundaries, I am less confident that we would consistently fire a finished or failed event paired with this submitted one in case of any unexpected errors. So, long story short, if something starts breaking horribly in how we deal with these planningAreaProtectedCalculation events, we should reassess this: probably keeping the event firing here, but adding more appropriately robust error handling, if needed.

@vercel
Copy link

vercel bot commented Feb 24, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

marxan – ./app

🔍 Inspect: https://vercel.com/vizzuality1/marxan/4Z7ME8a4FJdox5jWbUQTDPXYTzYF
✅ Preview: https://marxan-git-chore-apimarxan-1316fire-protecte-c2f3ab-vizzuality1.vercel.app

marxan-storybook – ./app

🔍 Inspect: https://vercel.com/vizzuality1/marxan-storybook/5fQxm33m3crLWDt6C2nP6nsfoXar
✅ Preview: https://marxan-storybook-git-chore-apimarxan-1316fir-7f29c6-vizzuality1.vercel.app

We did originally fire the event below in
`CalculatePlanningUnitsProtectionLevelHandler.execute()`, however this
would be *after* some potentially expensive SQL queries had been run in
`ScenarioPlanningUnitsProtectedStatusCalculatorService.calculatedProtectionStatusForPlanningUnitsIn()`,
which would lead is some cases to a very long delay between the time an
API user submits a request for `POST
/api/scenarios/:id/protected-areas` and the time a
`scenario.planningAreaProtectedCalculation.submitted/v1/alpha` event
shows up in the scenario status data.

However, as we're moving the firing of this event across a couple of
cqrs event boundaries, I am less confident that we would consistently
fire a `finished` or `failed` event paired with this `submitted` one in
case of any unexpected errors. So, long story short, if something
starts breaking horribly in how we deal with these
`planningAreaProtectedCalculation` events, we should reassess this:
probably keeping the event firing here, but adding more appropriately
robust error handling, if needed.
@hotzevzl hotzevzl force-pushed the chore/api/MARXAN-1316_fire-protected-percentage-calculation-submitted-event-earlier branch from 5a1b01b to 3a3f8c7 Compare February 24, 2022 19:26
@hotzevzl hotzevzl marked this pull request as ready for review February 24, 2022 19:53
@hotzevzl hotzevzl merged commit 92e1073 into develop Feb 25, 2022
@hotzevzl hotzevzl deleted the chore/api/MARXAN-1316_fire-protected-percentage-calculation-submitted-event-earlier branch February 25, 2022 12:18
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.

2 participants