Fixed legacy idVoie duplicates when exporting data from postgres to mongo #412
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 :
${cog}_${fantoirCode}
${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)${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)