Skip to content

Conversation

rowanseymour
Copy link
Member

No description provided.

@Copilot Copilot AI review requested due to automatic review settings September 1, 2025 21:55
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 the ticket note addition functionality to use event handling instead of direct database operations. The change moves from a synchronous database-first approach to an event-driven architecture using flow events and pre-commit hooks.

  • Replaced direct database calls with event-based processing using events.NewTicketNoteAdded
  • Introduced new pre-commit hooks for updating ticket activity and inserting legacy events
  • Removed the TicketsAddNote function and associated tests in favor of the new event-driven approach

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
web/ticket/add_note.go Refactored to use event-driven approach with scenes and flow events
core/runner/handlers/ticket_note_added.go New event handler for processing ticket note added events
core/runner/hooks/update_ticket_activity.go New pre-commit hook for updating ticket last activity
core/runner/hooks/insert_legacy_ticket_events.go Updated to handle ticket-event pairs and notifications
core/runner/handlers/ticket_topic_changed.go Updated to use new TicketAndEvent structure
core/models/ticket.go Removed deprecated TicketsAddNote function
core/models/ticket_test.go Removed tests for deprecated TicketsAddNote function
web/ticket/base_test.go Updated test reset mode for new event handling

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

for _, scene := range scenes {
for _, ticket := range scene.Tickets {
if err := scene.AddEvent(ctx, rt, oa, events.NewTicketNoteAdded(ticket.UUID(), r.Note), r.UserID); err != nil {
return nil, 0, fmt.Errorf("error adding ntoe added event to scene: %w", err)
Copy link
Preview

Copilot AI Sep 1, 2025

Choose a reason for hiding this comment

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

There is a typo in the error message: 'ntoe' should be 'note'.

Suggested change
return nil, 0, fmt.Errorf("error adding ntoe added event to scene: %w", err)
return nil, 0, fmt.Errorf("error adding note added event to scene: %w", err)

Copilot uses AI. Check for mistakes.

@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 32.89474% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.74%. Comparing base (6f97a27) to head (9f0b3f0).

Files with missing lines Patch % Lines
core/runner/handlers/ticket_note_added.go 10.52% 17 Missing ⚠️
core/runner/hooks/insert_notifications.go 0.00% 13 Missing ⚠️
core/runner/hooks/update_ticket_activity.go 0.00% 11 Missing ⚠️
web/ticket/add_note.go 53.84% 4 Missing and 2 partials ⚠️
core/runner/hooks/insert_tickets.go 0.00% 2 Missing ⚠️
core/models/ticket.go 0.00% 0 Missing and 1 partial ⚠️
core/runner/hooks/insert_legacy_ticket_events.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #775      +/-   ##
==========================================
- Coverage   50.88%   50.74%   -0.14%     
==========================================
  Files         253      256       +3     
  Lines       15198    15220      +22     
==========================================
- Hits         7733     7723      -10     
- Misses       6662     6696      +34     
+ Partials      803      801       -2     

☔ 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 f322b8c into main Sep 1, 2025
5 checks passed
@rowanseymour rowanseymour deleted the notes_by_events branch September 1, 2025 22:28
@github-actions github-actions bot locked and limited conversation to collaborators Sep 1, 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