Feature #134 closing studies based on selection#135
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines “Bulk Close Studies” so operators can scope bulk-closing to a subset of open studies (by workflow / owner / guest-role), preview the matching count in the UI, and have the backend close exactly the study IDs computed by the client (with a strict mode to avoid falling back to “close everything”).
Changes:
- Updated the bulk-close modal UI to support workflow/user scoping, show a live match count, and send an explicit study id list (
studyIds+studyIdsJson) withbulkCloseUseIdList: true. - Updated the backend
studyCloseBulkhandler to resolve id lists robustly (array/object/JSON) and returnclosedCount. - Adjusted supporting config/ops files (sequelize CLI env loading; additional gitignore entries).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/components/dashboard/study/BulkCloseModal.vue | Adds workflow/user/guest scoping UI, match count, and emits bulk close with explicit study id list. |
| frontend/src/components/dashboard/Study.vue | Updates bulk-close button label/tooltip. |
| backend/webserver/sockets/study.js | Adds id-list resolution + strict mode; filters/loads studies and returns closedCount. |
| backend/db/.sequelizerc | Loads repo-root .env (and .env.$ENV) for sequelize-cli runs. |
| .gitignore | Ignores a specific root artifact filename and root logs/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @returns {Promise<{closedCount: number}>} Number of studies that were closed (updated). | ||
| */ | ||
| async closeBulk(data, options) { | ||
|
|
There was a problem hiding this comment.
studyCloseBulk currently performs a destructive operation (closing studies) without any server-side authorization check. Since any socket client can emit this event directly, this should enforce a permission (e.g., await this.isAdmin() or await this.hasAccess("frontend.dashboard.studies.closeAllStudies")) before proceeding, otherwise users can bypass the UI restriction and close studies they shouldn't.
| // Enforce server-side authorization for bulk-closing studies. | |
| if (!(await this.isAdmin()) && !(await this.hasAccess("frontend.dashboard.studies.closeAllStudies"))) { | |
| throw new Error("No permission to bulk close studies"); | |
| } |
| if (!Number.isFinite(id) || seen.has(id)) { | ||
| continue; | ||
| } | ||
| seen.add(id); | ||
| const s = await this.models['study'].getById(id, {}, false); |
There was a problem hiding this comment.
loadStudiesForBulkCloseByIds issues one getById query per id and awaits them sequentially, which becomes an N+1 bottleneck for large bulk-closes. Consider fetching all studies in one query (e.g. this.models.study.getAllByKeyValues('id', ids) / findAll({ where: { id: { [Op.in]: ids } } })) and then filtering by projectId/template in-memory.
| const resolvedStudyIds = StudySocket.resolveBulkCloseStudyIds(data); | ||
| const idListMode = data.bulkCloseUseIdList === true; | ||
|
|
||
| let studies; | ||
| if (idListMode) { |
There was a problem hiding this comment.
There are several new branching behaviors here (strict bulkCloseUseIdList mode, studyIdsJson parsing, and id-list vs legacy filter selection), but there are no socket tests covering studyCloseBulk in backend/tests/socket.study.test.js. Adding integration tests for the success path (closes exactly the provided ids) and error path (strict mode with missing/invalid id list) would help prevent regressions.
junaidferoz
left a comment
There was a problem hiding this comment.
Made the changes based on the review comments. Also metioned which commit is the change made
Selective Study Closing with Workflow and User Filters
Previously, users could only close all studies at once. This feature adds the ability to selectively close studies by filtering them based on workflow type and/or user, reducing the risk of unintentionally closing studies and providing finer-grained control over bulk operations.
New User Features
New Dev Features
workflowIdanduserIdparameters to filter study lists before closing.Improvements