Skip to content

Conversation

@ycdzj
Copy link
Contributor

@ycdzj 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

Copilot AI review requested due to automatic review settings December 12, 2025 08:15
Copy link
Contributor

Copilot AI left a 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 resourceId column to the tasks table 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() to cancelTaskOrFail() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants