718 B · text History 4b6fe3b
defmodule OhMyExOhIrcd.Sightings.Sighting do
  @moduledoc """
  One "seen on this network" row. Sessions authenticated to an account
  share one row per account (`user_id`); anonymous sessions get one row
  per downcased nick (`nick_key`, `user_id` NULL). Written only by
  `OhMyExOhIrcd.Sightings`, which upserts on those keys.
  """

  use Ecto.Schema

  alias OhMyExOhIrcd.Accounts.User

  schema "user_sightings" do
    field :nick_key, :string
    field :nick, :string
    field :host, :string
    field :real_ip, :string
    field :first_seen_at, :utc_datetime
    field :last_seen_at, :utc_datetime
    field :last_quit_reason, :string

    belongs_to :user, User

    timestamps(type: :utc_datetime)
  end
end