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

avoid inserting duplicate feature_amounts_per_planning_unit rows over and over [MRXN23-609] #1683

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

hotzevzl
Copy link
Member

@hotzevzl hotzevzl commented Apr 19, 2024

https://vizzuality.atlassian.net/browse/MRXN23-609

This is only a fix for the bug. I recommend to add a migration that fixes existing duplicated data as a separate PR, to keep things manageable and fast-track this fix (if approved) to production.

There are no tests with this fix. It's going to be complicated to test this exhaustively within a limited development effort.

Copy link

vercel bot commented Apr 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marxan ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2024 7:03pm

@hotzevzl
Copy link
Member Author

the banality of evil... 🙄

geoprocessing-production=> select count(*) from (select distinct project_pu_id, count(*) from features_data where feature_id = 'e334efba-97f6-43de-bd6b-f08950e4af0d' group by project_pu_id) a;
 count
-------
 14163
(1 row)

and

geoprocessing-production=> select count(*) from feature_amounts_per_planning_unit where feature_id = 'e334efba-97f6-43de-bd6b-f08950e4af0d';
 count
--------
 119163
(1 row)
$$119163 = \sum_{1}^{14}1000*n + 14163$$

Another feature from the project we were using to triage this:

geoprocessing-production=> select count(*) from feature_amounts_per_planning_unit where feature_id = '30b39d9e-ba84-4188-9721-a50bb1458ae0';
 count
-------
 54266
(1 row)

geoprocessing-production=> select count(*) from features_data where feature_id = '30b39d9e-ba84-4188-9721-a50bb1458ae0';
 count
-------
  9266
(1 row)
$$54266 = \sum_{1}^{9}1000*n + 9266$$

I can run more exhaustive checks on Monday, but my bet is on this 😃

@hotzevzl hotzevzl merged commit eaf7a07 into develop Apr 23, 2024
61 checks passed
@hotzevzl hotzevzl deleted the fix/api/MRXN23-609_duplicated-features-data-rows branch April 23, 2024 11:34
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