Skip to content

Commit

Permalink
Intento de arreglar problema de relaciones de suscripciones en unific…
Browse files Browse the repository at this point in the history
…ación.
  • Loading branch information
c3r38r170 committed Apr 25, 2024
1 parent b1f23a6 commit 49e3f3c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions api/v1/pregunta.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ router.put('/:ID', function (req, res) {
// ,{model:ReportePost,include:{model:TipoReporte, as:'tipo',attributes:[]}}
]
},
{ model: SuscripcionesPregunta, as: 'suscripciones' },
{ model: SuscripcionesPregunta, as: 'suscripciones'},
{ model: Respuesta, as: 'respuestas', include: Post },
// TODO Refactor: Algún ENUM de tipos de reportes
]
Expand All @@ -269,7 +269,10 @@ router.put('/:ID', function (req, res) {
esperarA.push(pre.post.setEliminador(usuarioActual.DNI).then(p => p.save()));

// TODO Feature: Test this.
esperarA.push(pre.getSuscripciones().then(suscripciones => Promise.all(suscripciones.map(suscripcion => suscripcion.setPregunta(preguntaReemplazoID).then(s => s.save())))));
esperarA.push(pre.getSuscripciones().then(suscripciones => Promise.all(suscripciones.map(suscripcion =>{
suscripcion.preguntaID=preguntaReemplazoID;
return suscripcion.save();
}))));

// TODO Feature: ¿Pasar reportes de otras índoles?
// esperarA.push(pre.post.getReportePosts().then(reportes=>Promise.all(reportes.map(reporte => reporte.tipoID==2?/* ! 2 es pregunta repetida */reporte.destroy()))));
Expand Down

0 comments on commit 49e3f3c

Please sign in to comment.