<commit_before>defmodule Helix.NPC.Model.NPC do

  use Ecto.Schema

  alias HELL.PK

  import Ecto.Changeset

  @type t :: %__MODULE__{
    npc_id: PK.t,
    inserted_at: NaiveDateTime.t,
    updated_at: NaiveDateTime.t
  }

  @creation_fields ~w//a

  @primary_key false
  schema "npcs" do
    field :npc_id, HELL.PK,
      primary_key: true

    timestamps()
  end

  @spec create_changeset(%{}) :: Ecto.Changeset.t
  def create_changeset(params) do
    %__MODULE__{}
    |> cast(params, @creation_fields)
    |> put_primary_key()
  end

  @spec put_primary_key(Ecto.Changeset.t) :: Ecto.Changeset.t
  defp put_primary_key(changeset) do
    ip = PK.generate([0x0006, 0x0000, 0x0000])

    changeset
    |> cast(%{npc_id: ip}, [:npc_id])
  end
end<commit_msg>Update NPC primary key generation.<commit_after>defmodule Helix.NPC.Model.NPC do

  use Ecto.Schema

  alias HELL.PK

  import Ecto.Changeset

  @type t :: %__MODULE__{
    npc_id: PK.t,
    inserted_at: NaiveDateTime.t,
    updated_at: NaiveDateTime.t
  }

  @creation_fields ~w//a

  @primary_key false
  @ecto_autogenerate {:npc_id, {PK, :pk_for, [__MODULE__]}}
  schema "npcs" do
    field :npc_id, HELL.PK,
      primary_key: true

    timestamps()
  end

  @spec create_changeset(%{}) :: Ecto.Changeset.t
  def create_changeset(params) do
    %__MODULE__{}
    |> cast(params, @creation_fields)
  end
end
{'fraction_non_alphanumeric': 0.11970802919708029, 'fraction_numerical': 0.010948905109489052, 'mean_word_length': 3.3662420382165603, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3600964', 'n_tokens_mistral': 578, 'n_tokens_neox': 541, 'n_words': 110}