Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions tickets/common/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,18 @@ def record_ticket_closed(
)
)

# --- Staff Stats (only if a staff member closed it, not self-close) ---
# --- Staff Stats ---
# If a staff member closed it, they get the credit.
# On a self-close by the owner, fall back to the attributed staff member
# (claimer, or first responder) so they still receive close credit.
staff_credit_id: int | None = None
if closed_by_id != owner_id:
staff_stats = conf.get_staff_stats(closed_by_id)
staff_credit_id = closed_by_id
elif ticket.claimed_by is not None and ticket.claimed_by != owner_id:
staff_credit_id = ticket.claimed_by

if staff_credit_id is not None:
staff_stats = conf.get_staff_stats(staff_credit_id)
staff_stats.tickets_closed += 1
staff_stats.total_resolution_time += resolution_time
staff_stats.resolution_count += 1
Expand Down