Skip to content
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

pi-migration-delete-tasks #1929

Merged
merged 3 commits into from
Jul 16, 2024
Merged

pi-migration-delete-tasks #1929

merged 3 commits into from
Jul 16, 2024

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented Jul 16, 2024

Fixes #1909

This deletes tasks and bpmn processes out of the database if they were removed in a process instance migration. It also adds a test for timer events to make sure they can work as well.

Summary by CodeRabbit

  • New Features

    • Introduced migration handling for processes, allowing tasks and BPMN processes to be adjusted before and after migration.
  • Tests

    • Added new test workflows and methods to ensure accurate process instance migration and timer event handling.
  • Bug Fixes

    • Corrected date-time handling in various test methods for better consistency and reliability.

Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Walkthrough

Walkthrough

The changes introduce modifications to handle the migration of process instances involving timers in the BPMN workflow. New imports and variables are added to handle tasks before and after migration. The changes also include tests for the new migration functionality and updates to existing tests for accuracy.

Changes

File Change Summary
.../process_instance_service.py Added import for BpmnProcessModel, introduced variables pre_migration_tasks and post_migration_tasks, and logic to delete tasks and BPMN processes post-migration.
.../migration-test-with-timer/migration-initial.bpmn Added a BPMN XML definition for a process involving a timer event and script tasks to calculate start and end times with a duration display.
.../migration-test-with-timer/migration-new.bpmn Added a BPMN process similar to migration-initial.bpmn, including a timer event, script tasks to calculate times, and an end event to display the duration.
.../helpers/base_test.py Added imports for copy and datetime, SpiffTask, TaskModel, and flag_modified. Introduced methods set_timer_event_to_new_time and get_all_children_of_spiff_task.
.../unit/test_process_instance_service.py Updated imports and replaced timezone with datetime.timezone. Added a new test method test_it_can_migrate_a_process_instance_a_timer with assertions and setup logic for process instance migration and timer events.

Assessment against linked issues

Objective (Issue) Addressed Explanation
Handle timer update migration error (#1909)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9224fbb and 249aac1.

Files ignored due to path filters (1)
  • spiffworkflow-backend/poetry.lock is excluded by !**/*.lock
Files selected for processing (5)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py (3 hunks)
  • spiffworkflow-backend/tests/data/migration-test-with-timer/migration-initial.bpmn (1 hunks)
  • spiffworkflow-backend/tests/data/migration-test-with-timer/migration-new.bpmn (1 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py (5 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py (7 hunks)
Additional comments not posted (9)
spiffworkflow-backend/tests/data/migration-test-with-timer/migration-initial.bpmn (1)

1-106: Well-defined BPMN process for timer event handling.

The BPMN file is well-structured and defines a clear process involving start events, script tasks, intermediate catch events, and end events. The timer event is correctly defined with a repeating interval, which is crucial for the intended functionality.

spiffworkflow-backend/tests/data/migration-test-with-timer/migration-new.bpmn (1)

1-106: Updated timer settings in the new BPMN file.

The BPMN structure remains consistent with the initial version, with an updated timer setting from 60 seconds to 30 seconds. This change likely represents a scenario testing or process optimization. Ensure that this new setting aligns with the expected behavior and testing requirements.

spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py (3)

2-2: Adjusted imports and added new import for task model.

The changes in imports, including the addition of TaskModel, are appropriate for the new functionalities being tested. Ensure that these changes do not introduce any unresolved dependencies.

Also applies to: 16-16


123-123: Updated datetime references to fully qualified imports.

The changes from datetime.now(timezone.utc) to datetime.datetime.now(datetime.timezone.utc) are consistent and correct, reflecting the modified import statements. This ensures clarity in the code by using fully qualified names.

Also applies to: 134-134, 145-145, 157-157


417-490: Comprehensive test for process instance migration with a timer.

The new test method test_it_can_migrate_a_process_instance_a_timer is well-structured and covers a significant scenario involving timer events in process migration. It includes setup, execution, and assertion phases that are crucial for validating the migration logic.

spiffworkflow-backend/tests/spiffworkflow_backend/helpers/base_test.py (2)

1-2: Added necessary imports for new functionalities.

The imports added, including datetime, TaskModel, and flag_modified, are necessary for the new functionalities introduced in this file. These are used effectively in the new methods for handling timer events and tasks.

Also applies to: 15-15, 33-33, 42-42


653-672: New methods for handling timer events and tasks.

The methods set_timer_event_to_new_time and get_all_children_of_spiff_task are well-implemented, providing functionalities essential for manipulating timer events and navigating task hierarchies in tests. These methods enhance the testing capabilities for BPMN processes involving timers.

spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py (2)

43-43: Review of the new import statement.

The import of BpmnProcessModel is consistent with the summary that mentions new BPMN process definitions. Ensure that this model is utilized appropriately in the subsequent code.


234-239: Review of task state tracking variables.

The introduction of pre_migration_tasks and post_migration_tasks is appropriate for tracking the state of tasks before and after migration. This is crucial for understanding the changes and impacts of the migration process.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 249aac1 and 5122798.

Files selected for processing (1)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_service.py

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5122798 and c664a95.

Files ignored due to path filters (1)
  • spiffworkflow-backend/poetry.lock is excluded by !**/*.lock
Files selected for processing (1)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py

@jasquat jasquat merged commit 4992586 into main Jul 16, 2024
23 checks passed
@jasquat jasquat deleted the pi-migration-delete-tasks branch July 16, 2024 18:27
@coderabbitai coderabbitai bot mentioned this pull request Nov 27, 2024
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.

PI Migration - Timer update migration error
2 participants