PhoenixKit.Modules.Tickets.TicketStatusHistory (phoenix_kit v1.7.39)

Copy Markdown View Source

Schema for ticket status change audit trail.

Records every status transition for a ticket, including who made the change and an optional reason. Used for auditing and tracking ticket lifecycle.

Fields

  • ticket_id - Reference to the ticket
  • changed_by_id - User who made the status change
  • from_status - Previous status (nil for initial creation)
  • to_status - New status
  • reason - Optional explanation for the change

Examples

# Ticket created
%TicketStatusHistory{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  changed_by_id: 42,
  from_status: nil,
  to_status: "open",
  reason: nil
}

# Ticket assigned and moved to in_progress
%TicketStatusHistory{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  changed_by_id: 5,
  from_status: "open",
  to_status: "in_progress",
  reason: "Assigned to support team"
}

# Ticket resolved
%TicketStatusHistory{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  changed_by_id: 5,
  from_status: "in_progress",
  to_status: "resolved",
  reason: "Issue fixed in version 2.0.1"
}

# Ticket reopened
%TicketStatusHistory{
  ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
  changed_by_id: 42,
  from_status: "resolved",
  to_status: "open",
  reason: "Issue still occurring after update"
}

Summary

Functions

Changeset for creating a status history entry.

Check if this is a close transition.

Check if this is the initial creation record.

Check if this is a reopen transition.

Check if this is a resolution transition.

Types

t()

@type t() :: %PhoenixKit.Modules.Tickets.TicketStatusHistory{
  __meta__: term(),
  changed_by: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  changed_by_id: integer() | nil,
  changed_by_uuid: UUIDv7.t(),
  from_status: String.t() | nil,
  inserted_at: NaiveDateTime.t() | nil,
  reason: String.t() | nil,
  ticket:
    PhoenixKit.Modules.Tickets.Ticket.t() | Ecto.Association.NotLoaded.t(),
  ticket_id: UUIDv7.t(),
  to_status: String.t(),
  uuid: UUIDv7.t() | nil
}

Functions

changeset(history, attrs)

Changeset for creating a status history entry.

Required Fields

  • ticket_id - Reference to ticket
  • changed_by_uuid - User who made the change
  • to_status - New status

Note: from_status is optional (nil for ticket creation).

close?(arg1)

Check if this is a close transition.

creation?(arg1)

Check if this is the initial creation record.

reopen?(arg1)

Check if this is a reopen transition.

resolution?(arg1)

Check if this is a resolution transition.