Search documentation of phoenix_kit

# PhoenixKit.Modules.CustomerService.TicketStatusHistory (phoenix_kit v1.7.87)

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_uuid` - Reference to the ticket
- `changed_by_uuid` - 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_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      changed_by_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      from_status: nil,
      to_status: "open",
      reason: nil
    }

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

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

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

## Summary

### Types

t()

### Functions

changeset(history, attrs)

Changeset for creating a status history entry.

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.

## Types

# t()

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

## Functions

# changeset(history, attrs)

Changeset for creating a status history entry.

## Required Fields

- `ticket_uuid` - 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.