Skip to content

Conversation

rowanseymour
Copy link
Member

So stops from channel events are handled same as status=stopped changes in flows, and generate contact_status_changed events

@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 22:23
Copy link

@Copilot 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 refactors how contact stopping is handled by using the flow modifier system instead of direct database operations. The change ensures that channel event stops generate contact_status_changed events like regular flow status changes.

  • Replaces direct contact stopping with flow modifier application for consistency
  • Adds persistence configuration for contact_status_changed events
  • Updates tests to reflect the new event generation behavior

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
core/tasks/realtime/ctasks/event_received.go Replaces direct contact stopping with flow modifier application
core/models/event.go Adds persistence configuration for contact status changed events
core/models/contact.go Removes the direct Contact.Stop method
core/tasks/realtime/ctasks/event_received_test.go Updates test expectations for new event generation
core/runner/handlers/contact_status_changed_test.go Updates test expectations and SQL formatting
core/models/contact_test.go Removes test for deleted Contact.Stop method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +142 to +146
if t.EventType == models.EventTypeStopContact {
if _, err := scene.ApplyModifier(ctx, rt, oa, modifiers.NewStatus(flows.ContactStatusStopped), models.NilUserID); err != nil {
return nil, fmt.Errorf("error applying stop modifier: %w", err)
}
}
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

The stop contact handling should occur before trigger processing to maintain consistent event ordering. Consider moving this block before line 110 where trigger processing begins.

Copilot uses AI. Check for mistakes.

Comment on lines +36 to +37
testdb.InsertContactFire(rt, testdb.Org1, testdb.Cathy, models.ContactFireTypeCampaignPoint, fmt.Sprintf("%d:1", testdb.RemindersPoint1.ID), time.Now(), "")
testdb.InsertContactFire(rt, testdb.Org1, testdb.George, models.ContactFireTypeCampaignPoint, fmt.Sprintf("%d:1", testdb.RemindersPoint1.ID), time.Now(), "")
Copy link
Preview

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

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

Magic number '1' in the campaign point format string is unexplained. Consider adding a comment to clarify what this number represents or define it as a named constant.

Copilot uses AI. Check for mistakes.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.04%. Comparing base (32a8542) to head (f72b105).

Files with missing lines Patch % Lines
core/tasks/realtime/ctasks/event_received.go 12.50% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #769   +/-   ##
=======================================
  Coverage   51.03%   51.04%           
=======================================
  Files         250      250           
  Lines       15153    15132   -21     
=======================================
- Hits         7734     7724   -10     
+ Misses       6615     6608    -7     
+ Partials      804      800    -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rowanseymour rowanseymour merged commit 7e87180 into main Aug 28, 2025
5 checks passed
@rowanseymour rowanseymour deleted the stop_by_modifier branch August 28, 2025 22:53
@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants