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

オープン
#1,883 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
53/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
node.js, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
119
フォーク
19
平均マージ
1日 18時間
マージ済み PR(30日)
61

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

DouglasNeuroInformatics/OpenDataCapture のほかの issue

DouglasNeuroInformatics/OpenDataCapture の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。