-
Notifications
You must be signed in to change notification settings - Fork 5
refactor(tasks): cancel tasks on resource deletion #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
ycdzj
commented
Dec 12, 2025
- refactor(tasks): update cancelTask
- refactor(resources): update deleteResource
- refactor(tasks): add resourceId
- refactor(tasks): include resourceId in emitTask
- refactor(tasks): cancel tasks on resource deletion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements automatic task cancellation when resources are deleted, improving data consistency by preventing orphaned tasks from attempting to operate on deleted resources.
Key changes:
- Added a
resourceIdcolumn to thetaskstable to enable efficient querying of resource-related tasks - Implemented
cancelResourceTasks()method to cancel all active tasks associated with a deleted resource - Integrated task cancellation into the resource deletion workflow
- Renamed
cancelTask()tocancelTaskOrFail()for clarity
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/migrations/1765443191000-add-resource-id-to-tasks.ts | Adds new migration to create resource_id column with foreign key constraint to resources table |
| src/tasks/tasks.entity.ts | Adds nullable resourceId column to Task entity |
| src/tasks/tasks.service.ts | Implements emitTask to populate resourceId from payload, adds cancelResourceTasks method, renames cancelTask to cancelTaskOrFail |
| src/tasks/tasks.controller.ts | Updates controller to use renamed cancelTaskOrFail method |
| src/tasks/wizard-task.service.ts | Refactors emitDeleteIndexTask to accept decomposed parameters instead of Resource object |
| src/resources/resources.service.ts | Adds userId parameter to deleteResource, integrates task cancellation and delete index task emission, updates transaction handling pattern |
| src/namespaces/namespaces.service.ts | Updates calls to deleteResource and restoreResource to pass Transaction objects instead of EntityManager |
| src/namespace-resources/namespace-resources.service.ts | Simplifies delete logic by delegating to ResourcesService.deleteResource |
| src/app/app.module.ts | Registers new migration in migrations array |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.