Deleting an instrument record leaves an orphaned session, and no endpoint can delete a session

Abierto
#1,883 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
53/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript

Línea de trabajo

Start with apps/api/src/instrument-records/instrument-records.service.ts and SessionsController to trace record deletion, session references, and the existing session routes. The issue lists three possible approaches but does not choose one; clarify the intended scope and check the relevant tests before making a change. Done means preventing or removing orphaned sessions as agreed, while preserving sessions that still have records.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Area: API Bug Difficulty: Medium Needs Decision Priority: Medium

Problem

Deleting an instrument record leaves its session in the database, and no endpoint can delete a session.

  • InstrumentRecordsService.deleteById (apps/api/src/instrument-records/instrument-records.service.ts) deletes the record and its files only.
  • SessionsController has only POST /sessions and GET /sessions.
  • The only path that deletes sessions is DELETE /subjects/:id?force=true, which deletes the whole subject.

Every session created by the bulk upload or by a form holds exactly one record, so each record delete leaves an empty session. These sessions:

  • count toward GET /summary counts.sessions and its trend,
  • appear in the session list and the subject's session history,
  • cannot be removed by an admin without direct database access.

Observed

On a production instance (v2.5.2), a cleanup of about 26,000 duplicate bulk-uploaded records through DELETE /instrument-records/:id would leave about 26,000 empty sessions. Before any cleanup, that instance already has 79 sessions with no record.

Options

  1. In deleteById, also delete the record's session in the same transaction when no other record references it.
  2. Add DELETE /sessions/:id (@RouteAccess({ action: 'delete', subject: 'Session' })), rejected while the session still has records.
  3. Both.

Option 1 stops new orphans. Option 2 (or a one-off migration) is still necessary to remove the sessions that are already orphaned.

Lenguaje dominante
TypeScript
Estrellas
119
Forks
19
Merge medio
1 d 18 h
PR fusionados (30 d)
61

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DouglasNeuroInformatics/OpenDataCapture

Todos los issues de DouglasNeuroInformatics/OpenDataCapture

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.