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

Fixed legacy idVoie duplicates when exporting data from postgres to mongo #412

Conversation

antoineludeau
Copy link
Member

@antoineludeau antoineludeau commented May 14, 2024

Context

When using the new technical architecture (new APIs and new postgres DB), we export the data from postgres to mongo when we detect a change. If the script that export data from postgres to mongo, we are calculating the 'legacy' id for the addresses and the common toponyms. In the 'legacy' compose, there were simplifications to have a unique identifier for those legacy ids. In the new technical architecture, as we based the unicity of addresses and common toponyms on their new ban IDs, the 'legacy' can sometimes not be unique (as calculated with fantoir code or pseudo code that can be the same for different entities).

Enhancement

This PR aims to make sure the legacy id for the common toponyms is unique. Here is the mechanism :

  • If a fantoir code is found on a common toponym, we create a legacy id with the following model : ${cog}_${fantoirCode}
  • if no fantoir is found or if the generated id ${cog}_${fantoirCode} is already used for another common toponym, we create a legacy id with the following model : ${cog}_${pseudoCode} (the pseudo code calculation is the same as the one done in the legacy composition)
  • if the id ${cog}_${pseudoCode} is also already used, we generate a legacy id with the model ${cog}_${hash} (the hash is calculated thanks to the new banID)

@antoineludeau antoineludeau force-pushed the antoineludeau/fix-duplicate-legacy-idvoie-during-export-from-postgres-to-mongo branch from 4263eb1 to 72a79a2 Compare May 14, 2024 15:25
@antoineludeau antoineludeau force-pushed the antoineludeau/fix-duplicate-legacy-idvoie-during-export-from-postgres-to-mongo branch from 72a79a2 to 5fc808a Compare May 15, 2024 08:03
@antoineludeau antoineludeau merged commit 4e1ad51 into master May 15, 2024
1 check passed
@antoineludeau antoineludeau deleted the antoineludeau/fix-duplicate-legacy-idvoie-during-export-from-postgres-to-mongo branch May 22, 2024 13:14
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