(fix): TM farmacia cuit sin guiones#2257
Open
agustin1996ra wants to merge 1 commit into
Open
Conversation
9 tasks
75a7ae1 to
3c389aa
Compare
3c389aa to
d59aa48
Compare
MarianoCampetella
requested changes
Jun 17, 2026
Comment on lines
+5
to
+11
| const farmacias = await Farmacia.find({ cuit: { $regex: /-/ } }); | ||
| for (const farmacia of farmacias) { | ||
| if (farmacia.cuit) { | ||
| farmacia.cuit = farmacia.cuit.replace(/[^\d]/g, ''); | ||
| await Farmacia.update({ _id: farmacia._id }, { $set: { cuit: farmacia.cuit } }); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Dentro del try {...} podríamos remplazar por el siguiente código:
const farmacias = await Farmacia.find({ cuit: { $regex: /-/ } }).lean();
if (farmacias.length === 0) return done();
const operations = farmacias.map(farmacia => ({
updateOne: {
filter: { _id: farmacia._id },
update: { $set: { cuit: farmacia.cuit.replace(/[^\d]/g, '') } }
}
}));
await Farmacia.bulkWrite(operations);
- Se agrega .lean() para ir más rápido
- Se quita el for ... of junto con el update para que no se tenga que acceder X cantidades de veces a la base de datos (sobre todo cuando se ejecute en prod) cada vez que se tenga que actualizar una farmacia. Para ello se puede emplear un bulkWrite o updateMany para enviar las actualizaciones en lotes.
d59aa48 to
6c2cf07
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Este pr rompe app, si app no se actualiza con este pr:
andes/app#3370
Requerimiento
Las farmacias no macheaban en la consulta del auto registro desde recetar.
Funcionalidad desarrollada
UserStories llegó a completarse
Requiere actualizaciones en la base de datos
Requiere script:
api/scripts/fix-cuit-farmacias.jscomando necesario desde terminal apuntando a produccion: