Skip to content

Conversation

rowanseymour
Copy link
Member

No description provided.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 32.75862% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.16%. Comparing base (666960a) to head (3db04e2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
core/tickets/modifiers.go 0.00% 28 Missing ⚠️
web/ticket/change_topic.go 42.85% 2 Missing and 2 partials ⚠️
web/ticket/base.go 75.00% 2 Missing and 1 partial ⚠️
web/ticket/add_note.go 66.66% 1 Missing and 1 partial ⚠️
web/ticket/assign.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #779      +/-   ##
==========================================
- Coverage   50.28%   50.16%   -0.12%     
==========================================
  Files         259      260       +1     
  Lines       15227    15253      +26     
==========================================
- Hits         7657     7652       -5     
- Misses       6771     6801      +30     
- Partials      799      800       +1     

☔ 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 marked this pull request as ready for review September 2, 2025 20:39
@Copilot Copilot AI review requested due to automatic review settings September 2, 2025 20:39
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 introduces a ticket modifier pattern to consolidate duplicate logic across ticket operations. The changes refactor ticket assignment, topic changes, and note addition to use a common modifier pattern instead of handling event creation and ticket updates inline.

  • Introduces a new TicketModifier function type and factory functions for different ticket operations
  • Refactors existing ticket handlers to use the new modifier pattern with a shared ApplyTicketModifier function
  • Eliminates duplicate logic across ticket operations while maintaining the same functionality

Reviewed Changes

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

Show a summary per file
File Description
core/tickets/modifiers.go New file implementing the modifier pattern with factory functions for assignment, note, and topic operations
web/ticket/base.go Adds shared ApplyTicketModifier function to handle modifier application and event logging
web/ticket/change_topic.go Refactored to use the new topic modifier instead of inline topic change logic
web/ticket/assign.go Refactored to use the new assignment modifier and removed the now-unused getOrgUser helper
web/ticket/add_note.go Refactored to use the new note modifier instead of inline note addition logic

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

Comment on lines +14 to +20
newAssignee := oa.UserByID(assigneeID)

return func(ticket *models.Ticket, log flows.EventCallback) bool {
if ticket.AssigneeID != assigneeID {
prevAssignee := oa.UserByID(ticket.AssigneeID)
ticket.AssigneeID = assigneeID
log(events.NewTicketAssigneeChanged(ticket.UUID, newAssignee.Reference(), prevAssignee.Reference()))
Copy link
Preview

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

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

Potential nil pointer dereference when calling newAssignee.Reference() or prevAssignee.Reference(). If assigneeID is models.NilUserID or refers to a non-existent user, oa.UserByID() will return nil, causing a panic when .Reference() is called.

Suggested change
newAssignee := oa.UserByID(assigneeID)
return func(ticket *models.Ticket, log flows.EventCallback) bool {
if ticket.AssigneeID != assigneeID {
prevAssignee := oa.UserByID(ticket.AssigneeID)
ticket.AssigneeID = assigneeID
log(events.NewTicketAssigneeChanged(ticket.UUID, newAssignee.Reference(), prevAssignee.Reference()))
var newRef, prevRef string
if newAssignee != nil {
newRef = newAssignee.Reference()
} else {
newRef = ""
}
if prevAssignee != nil {
prevRef = prevAssignee.Reference()
} else {
prevRef = ""
}
log(events.NewTicketAssigneeChanged(ticket.UUID, newRef, prevRef))

Copilot uses AI. Check for mistakes.

@rowanseymour rowanseymour merged commit 9d8d9cf into main Sep 2, 2025
5 checks passed
@rowanseymour rowanseymour deleted the ticket_modifiers branch September 2, 2025 20:41
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 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