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

feature/move-message-start-events #1070

Merged
merged 2 commits into from
Feb 20, 2024
Merged

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented Feb 19, 2024

Implements #1027

This adds a "file_name" column to message_triggerable_process_model and will delete the process from the table if it is no longer found in the file when updating the cache for that file.

Summary by CodeRabbit

  • New Features
    • Introduced an attribute to enhance process model identification.
  • Refactor
    • Enhanced message trigger handling for improved process associations and cache management.
  • Tests
    • Added tests to ensure proper deletion of unreferenced message start events.

Copy link
Contributor

coderabbitai bot commented Feb 19, 2024

Walkthrough

The update introduces a new attribute file_name to the MessageTriggerableProcessModel class, enhances the update_message_trigger_cache method to manage associations between message names and process models effectively, and adds a test to ensure message start events are correctly deleted if not referenced by a model. These changes aim to improve the handling of message-triggered processes within the system.

Changes

File Path Change Summary
.../models/message_triggerable_process_model.py Added file_name attribute to MessageTriggerableProcessModel.
.../services/spec_file_service.py Updated update_message_trigger_cache to handle message triggerable processes.
.../tests/.../test_message_service.py Added test for deleting unreferenced message start events.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between dc14af7 and 5c97485.
Files ignored due to path filters (1)
  • spiffworkflow-backend/migrations/versions/c6e246c3c04e_.py is excluded by: !spiffworkflow-backend/migrations/**
Files selected for processing (3)
  • spiffworkflow-backend/src/spiffworkflow_backend/models/message_triggerable_process_model.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/spec_file_service.py (2 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_message_service.py (2 hunks)
Additional comments: 2
spiffworkflow-backend/src/spiffworkflow_backend/models/message_triggerable_process_model.py (1)
  • 11-11: The addition of the file_name attribute to the MessageTriggerableProcessModel class looks good and follows the established pattern for defining model attributes. Ensure that the corresponding database migration script is in place to add this column to the database.
spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_message_service.py (1)
  • 257-291: The new test method test_can_delete_message_start_events_from_database_if_model_no_longer_references_it is well-structured and effectively tests the functionality of deleting obsolete message start events from the database. Ensure that additional tests are in place to cover edge cases and scenarios where multiple message start events might be affected.

Comment on lines 321 to 340
message_triggerable_process_model = MessageTriggerableProcessModel(
message_name=message_name,
process_model_identifier=ref.relative_location,
file_name=ref.file_name,
)
db.session.add(message_triggerable_process_model)
else:
if message_triggerable_process_model.process_model_identifier != ref.relative_location:
raise ProcessModelFileInvalidError(
f"Message model is already used to start process model {ref.relative_location}"
)
elif message_triggerable_process_model.file_name is None:
message_triggerable_process_model.file_name = ref.file_name
db.session.add(message_triggerable_process_model)
current_triggerable_processes.remove(message_triggerable_process_model)
for trigger_pm in current_triggerable_processes:
db.session.delete(trigger_pm)

@staticmethod
def update_correlation_cache(ref: Reference) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [313-337]

The updates to the update_message_trigger_cache method incorporate necessary logic for managing message triggerable processes in relation to their associated files. However, modifying a list (current_triggerable_processes) while iterating over it could lead to unexpected behavior. Consider using a different approach, such as filtering the list comprehensively before the loop or accumulating items to delete in a separate list and deleting them in a subsequent step, to avoid potential issues.

- for trigger_pm in current_triggerable_processes:
-     db.session.delete(trigger_pm)
+ to_delete = [trigger_pm for trigger_pm in current_triggerable_processes if condition]
+ for trigger_pm in to_delete:
+     db.session.delete(trigger_pm)

@burnettk burnettk merged commit 4ee2a28 into main Feb 20, 2024
22 checks passed
@burnettk burnettk deleted the feature/move-message-start-events branch February 20, 2024 15:44
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.

None yet

2 participants