improve accuracy of timestamps
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
e2c17b6b51
commit
c7bd7238c6
@ -1,6 +1,7 @@
|
|||||||
# v0.9.14
|
# v0.9.14
|
||||||
- Update deps
|
- Update deps
|
||||||
- Fix wrapping issues with search bars
|
- Fix wrapping issues with search bars
|
||||||
|
- Improve accuracy of timestamps
|
||||||
|
|
||||||
# v0.9.13
|
# v0.9.13
|
||||||
- Add button to resend email verification email
|
- Add button to resend email verification email
|
||||||
|
@ -10,7 +10,7 @@ import Config
|
|||||||
config :cannery,
|
config :cannery,
|
||||||
env: :dev,
|
env: :dev,
|
||||||
ecto_repos: [Cannery.Repo],
|
ecto_repos: [Cannery.Repo],
|
||||||
generators: [binary_id: true, timestamp_type: :utc_datetime]
|
generators: [binary_id: true, timestamp_type: :utc_datetime_usec]
|
||||||
|
|
||||||
config :cannery, Cannery.Accounts, registration: System.get_env("REGISTRATION", "invite")
|
config :cannery, Cannery.Accounts, registration: System.get_env("REGISTRATION", "invite")
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ defmodule Cannery do
|
|||||||
|
|
||||||
@primary_key {:id, :binary_id, autogenerate: true}
|
@primary_key {:id, :binary_id, autogenerate: true}
|
||||||
@foreign_key_type :binary_id
|
@foreign_key_type :binary_id
|
||||||
|
@timestamps_opts [type: :utc_datetime_usec]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ defmodule Cannery.Accounts.Invite do
|
|||||||
field :name, :string
|
field :name, :string
|
||||||
field :token, :string
|
field :token, :string
|
||||||
field :uses_left, :integer, default: nil
|
field :uses_left, :integer, default: nil
|
||||||
field :disabled_at, :naive_datetime
|
field :disabled_at, :utc_datetime_usec
|
||||||
|
|
||||||
belongs_to :created_by, User
|
belongs_to :created_by, User
|
||||||
|
|
||||||
has_many :users, User
|
has_many :users, User
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -25,12 +25,12 @@ defmodule Cannery.Accounts.Invite do
|
|||||||
name: String.t(),
|
name: String.t(),
|
||||||
token: token(),
|
token: token(),
|
||||||
uses_left: integer() | nil,
|
uses_left: integer() | nil,
|
||||||
disabled_at: NaiveDateTime.t(),
|
disabled_at: DateTime.t(),
|
||||||
created_by: User.t() | nil | Association.NotLoaded.t(),
|
created_by: User.t() | nil | Association.NotLoaded.t(),
|
||||||
created_by_id: User.id() | nil,
|
created_by_id: User.id() | nil,
|
||||||
users: [User.t()] | Association.NotLoaded.t(),
|
users: [User.t()] | Association.NotLoaded.t(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_invite :: %__MODULE__{}
|
@type new_invite :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -123,7 +123,7 @@ defmodule Cannery.Accounts.Invites do
|
|||||||
end
|
end
|
||||||
|
|
||||||
defp decrement_invite_changeset(%Invite{uses_left: 1} = invite) do
|
defp decrement_invite_changeset(%Invite{uses_left: 1} = invite) do
|
||||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
now = DateTime.utc_now()
|
||||||
invite |> Invite.update_changeset(%{uses_left: 0, disabled_at: now})
|
invite |> Invite.update_changeset(%{uses_left: 0, disabled_at: now})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ defmodule Cannery.Accounts.User do
|
|||||||
field :password, :string, virtual: true
|
field :password, :string, virtual: true
|
||||||
field :hashed_password, :string
|
field :hashed_password, :string
|
||||||
field :current_password, :string, virtual: true, redact: true
|
field :current_password, :string, virtual: true, redact: true
|
||||||
field :confirmed_at, :naive_datetime
|
field :confirmed_at, :utc_datetime_usec
|
||||||
field :role, Ecto.Enum, values: [:admin, :user], default: :user
|
field :role, Ecto.Enum, values: [:admin, :user], default: :user
|
||||||
field :locale, :string
|
field :locale, :string
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ defmodule Cannery.Accounts.User do
|
|||||||
|
|
||||||
belongs_to :invite, Invite
|
belongs_to :invite, Invite
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %User{
|
@type t :: %User{
|
||||||
@ -38,14 +38,14 @@ defmodule Cannery.Accounts.User do
|
|||||||
email: String.t(),
|
email: String.t(),
|
||||||
password: String.t(),
|
password: String.t(),
|
||||||
hashed_password: String.t(),
|
hashed_password: String.t(),
|
||||||
confirmed_at: NaiveDateTime.t(),
|
confirmed_at: DateTime.t(),
|
||||||
role: role(),
|
role: role(),
|
||||||
locale: String.t() | nil,
|
locale: String.t() | nil,
|
||||||
created_invites: [Invite.t()] | Association.NotLoaded.t(),
|
created_invites: [Invite.t()] | Association.NotLoaded.t(),
|
||||||
invite: Invite.t() | nil | Association.NotLoaded.t(),
|
invite: Invite.t() | nil | Association.NotLoaded.t(),
|
||||||
invite_id: Invite.id() | nil,
|
invite_id: Invite.id() | nil,
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_user :: %User{}
|
@type new_user :: %User{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
@ -168,7 +168,7 @@ defmodule Cannery.Accounts.User do
|
|||||||
"""
|
"""
|
||||||
@spec confirm_changeset(t() | changeset()) :: changeset()
|
@spec confirm_changeset(t() | changeset()) :: changeset()
|
||||||
def confirm_changeset(user_or_changeset) do
|
def confirm_changeset(user_or_changeset) do
|
||||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
now = DateTime.utc_now()
|
||||||
user_or_changeset |> change(confirmed_at: now)
|
user_or_changeset |> change(confirmed_at: now)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ defmodule Cannery.Accounts.UserToken do
|
|||||||
sent_to: String.t(),
|
sent_to: String.t(),
|
||||||
user: User.t() | Association.NotLoaded.t(),
|
user: User.t() | Association.NotLoaded.t(),
|
||||||
user_id: User.id() | nil,
|
user_id: User.id() | nil,
|
||||||
inserted_at: NaiveDateTime.t()
|
inserted_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_user_token :: %__MODULE__{}
|
@type new_user_token :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -24,7 +24,7 @@ defmodule Cannery.ActivityLog.ShotRecord do
|
|||||||
field :user_id, :binary_id
|
field :user_id, :binary_id
|
||||||
field :pack_id, :binary_id
|
field :pack_id, :binary_id
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -34,8 +34,8 @@ defmodule Cannery.ActivityLog.ShotRecord do
|
|||||||
date: Date.t() | nil,
|
date: Date.t() | nil,
|
||||||
pack_id: Pack.id(),
|
pack_id: Pack.id(),
|
||||||
user_id: User.id(),
|
user_id: User.id(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_shot_record :: %__MODULE__{}
|
@type new_shot_record :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -920,7 +920,7 @@ defmodule Cannery.Ammo do
|
|||||||
multiplier <= @pack_create_limit and
|
multiplier <= @pack_create_limit and
|
||||||
type_id |> is_binary() and
|
type_id |> is_binary() and
|
||||||
container_id |> is_binary() do
|
container_id |> is_binary() do
|
||||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
now = DateTime.utc_now()
|
||||||
|
|
||||||
changesets =
|
changesets =
|
||||||
Enum.map(1..multiplier, fn _count ->
|
Enum.map(1..multiplier, fn _count ->
|
||||||
|
@ -30,7 +30,7 @@ defmodule Cannery.Ammo.Pack do
|
|||||||
field :container_id, :binary_id
|
field :container_id, :binary_id
|
||||||
field :user_id, :binary_id
|
field :user_id, :binary_id
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -44,8 +44,8 @@ defmodule Cannery.Ammo.Pack do
|
|||||||
type_id: Type.id(),
|
type_id: Type.id(),
|
||||||
container_id: Container.id(),
|
container_id: Container.id(),
|
||||||
user_id: User.id(),
|
user_id: User.id(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_pack :: %__MODULE__{}
|
@type new_pack :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -90,7 +90,7 @@ defmodule Cannery.Ammo.Type do
|
|||||||
field :user_id, :binary_id
|
field :user_id, :binary_id
|
||||||
has_many :packs, Pack
|
has_many :packs, Pack
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -129,8 +129,8 @@ defmodule Cannery.Ammo.Type do
|
|||||||
dram_equivalent: String.t() | nil,
|
dram_equivalent: String.t() | nil,
|
||||||
user_id: User.id(),
|
user_id: User.id(),
|
||||||
packs: [Pack.t()] | nil,
|
packs: [Pack.t()] | nil,
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_type :: %__MODULE__{}
|
@type new_type :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -27,7 +27,7 @@ defmodule Cannery.Containers.Container do
|
|||||||
|
|
||||||
many_to_many :tags, Tag, join_through: ContainerTag
|
many_to_many :tags, Tag, join_through: ContainerTag
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -39,8 +39,8 @@ defmodule Cannery.Containers.Container do
|
|||||||
type: String.t(),
|
type: String.t(),
|
||||||
user_id: User.id(),
|
user_id: User.id(),
|
||||||
tags: [Tag.t()] | nil,
|
tags: [Tag.t()] | nil,
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_container :: %__MODULE__{}
|
@type new_container :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -11,7 +11,7 @@ defmodule Cannery.Containers.ContainerTag do
|
|||||||
belongs_to :container, Container
|
belongs_to :container, Container
|
||||||
belongs_to :tag, Tag
|
belongs_to :tag, Tag
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -20,8 +20,8 @@ defmodule Cannery.Containers.ContainerTag do
|
|||||||
container_id: Container.id(),
|
container_id: Container.id(),
|
||||||
tag: Tag.t(),
|
tag: Tag.t(),
|
||||||
tag_id: Tag.id(),
|
tag_id: Tag.id(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_container_tag :: %__MODULE__{}
|
@type new_container_tag :: %__MODULE__{}
|
||||||
@type id :: UUID.t()
|
@type id :: UUID.t()
|
||||||
|
@ -20,7 +20,7 @@ defmodule Cannery.Containers.Tag do
|
|||||||
|
|
||||||
field :user_id, :binary_id
|
field :user_id, :binary_id
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime_usec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
@ -29,8 +29,8 @@ defmodule Cannery.Containers.Tag do
|
|||||||
bg_color: String.t(),
|
bg_color: String.t(),
|
||||||
text_color: String.t(),
|
text_color: String.t(),
|
||||||
user_id: User.id(),
|
user_id: User.id(),
|
||||||
inserted_at: NaiveDateTime.t(),
|
inserted_at: DateTime.t(),
|
||||||
updated_at: NaiveDateTime.t()
|
updated_at: DateTime.t()
|
||||||
}
|
}
|
||||||
@type new_tag() :: %__MODULE__{}
|
@type new_tag() :: %__MODULE__{}
|
||||||
@type id() :: UUID.t()
|
@type id() :: UUID.t()
|
||||||
|
@ -136,7 +136,7 @@ defmodule CanneryWeb.CoreComponents do
|
|||||||
attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil"
|
attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil"
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Phoenix.Component for a <time> element that renders the naivedatetime in the
|
Phoenix.Component for a <time> element that renders the DateTime in the
|
||||||
user's local timezone
|
user's local timezone
|
||||||
"""
|
"""
|
||||||
def datetime(assigns)
|
def datetime(assigns)
|
||||||
@ -153,8 +153,8 @@ defmodule CanneryWeb.CoreComponents do
|
|||||||
"""
|
"""
|
||||||
def date_range(assigns)
|
def date_range(assigns)
|
||||||
|
|
||||||
@spec cast_datetime(NaiveDateTime.t() | nil) :: String.t()
|
@spec cast_datetime(DateTime.t() | nil) :: String.t()
|
||||||
defp cast_datetime(%NaiveDateTime{} = datetime) do
|
defp cast_datetime(%DateTime{} = datetime) do
|
||||||
datetime |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601(:extended)
|
datetime |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601(:extended)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ defmodule CanneryWeb.InviteLive.Index do
|
|||||||
%{"id" => id},
|
%{"id" => id},
|
||||||
%{assigns: %{current_user: current_user}} = socket
|
%{assigns: %{current_user: current_user}} = socket
|
||||||
) do
|
) do
|
||||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
now = DateTime.utc_now()
|
||||||
|
|
||||||
socket =
|
socket =
|
||||||
Invites.get_invite!(id, current_user)
|
Invites.get_invite!(id, current_user)
|
||||||
|
@ -10,7 +10,7 @@ defmodule Cannery.Repo.Migrations.CreateUsersAuthTables do
|
|||||||
add :hashed_password, :string, null: false
|
add :hashed_password, :string, null: false
|
||||||
add :confirmed_at, :naive_datetime
|
add :confirmed_at, :naive_datetime
|
||||||
add :role, :string
|
add :role, :string
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create unique_index(:users, [:email])
|
create unique_index(:users, [:email])
|
||||||
|
@ -10,7 +10,7 @@ defmodule Cannery.Repo.Migrations.CreateTags do
|
|||||||
|
|
||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:tags, [:user_id])
|
create index(:tags, [:user_id])
|
||||||
|
@ -31,7 +31,7 @@ defmodule Cannery.Repo.Migrations.CreateAmmoTypes do
|
|||||||
|
|
||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateContainers do
|
|||||||
|
|
||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:containers, [:user_id])
|
create index(:containers, [:user_id])
|
||||||
|
@ -12,7 +12,7 @@ defmodule Cannery.Repo.Migrations.CreateAmmoGroups do
|
|||||||
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
|
add :container_id, references(:containers, on_delete: :nothing, type: :binary_id)
|
||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:ammo_groups, [:ammo_type_id])
|
create index(:ammo_groups, [:ammo_type_id])
|
||||||
|
@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateInvites do
|
|||||||
|
|
||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:invites, [:user_id])
|
create index(:invites, [:user_id])
|
||||||
|
@ -8,7 +8,7 @@ defmodule Cannery.Repo.Migrations.CreateContainerTags do
|
|||||||
add :container_id, references(:containers, on_delete: :delete_all, type: :binary_id)
|
add :container_id, references(:containers, on_delete: :delete_all, type: :binary_id)
|
||||||
add :tag_id, references(:tags, on_delete: :delete_all, type: :binary_id)
|
add :tag_id, references(:tags, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:container_tags, [:container_id])
|
create index(:container_tags, [:container_id])
|
||||||
|
@ -11,7 +11,7 @@ defmodule Cannery.Repo.Migrations.CreateShotGroups do
|
|||||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||||
add :ammo_group_id, references(:ammo_groups, on_delete: :delete_all, type: :binary_id)
|
add :ammo_group_id, references(:ammo_groups, on_delete: :delete_all, type: :binary_id)
|
||||||
|
|
||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
create index(:shot_groups, [:id])
|
create index(:shot_groups, [:id])
|
||||||
|
52
priv/repo/migrations/20250405004036_set_utc_datetime.exs
Normal file
52
priv/repo/migrations/20250405004036_set_utc_datetime.exs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
defmodule Cannery.Repo.Migrations.SetUtcDatetime do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:users) do
|
||||||
|
modify :confirmed_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:users_tokens) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:tags) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:types) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:containers) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:packs) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:invites) do
|
||||||
|
modify :disabled_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:container_tags) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
alter table(:shot_records) do
|
||||||
|
modify :inserted_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
modify :updated_at, :utc_datetime_usec, from: :naive_datetime
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -131,8 +131,8 @@ defmodule CanneryWeb.ExportControllerTest do
|
|||||||
"id" => current_user.id,
|
"id" => current_user.id,
|
||||||
"locale" => current_user.locale,
|
"locale" => current_user.locale,
|
||||||
"role" => to_string(current_user.role),
|
"role" => to_string(current_user.role),
|
||||||
"inserted_at" => current_user.inserted_at |> NaiveDateTime.to_iso8601(),
|
"inserted_at" => current_user.inserted_at |> DateTime.to_iso8601(),
|
||||||
"updated_at" => current_user.updated_at |> NaiveDateTime.to_iso8601()
|
"updated_at" => current_user.updated_at |> DateTime.to_iso8601()
|
||||||
}
|
}
|
||||||
|
|
||||||
json_resp = conn |> json_response(200)
|
json_resp = conn |> json_response(200)
|
||||||
|
@ -305,7 +305,7 @@ defmodule CanneryWeb.ContainerLiveTest do
|
|||||||
{:ok, _show_live, html} = live(conn, ~p"/container/#{container}")
|
{:ok, _show_live, html} = live(conn, ~p"/container/#{container}")
|
||||||
|
|
||||||
assert html =~ type_name
|
assert html =~ type_name
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "displays pack in table",
|
test "displays pack in table",
|
||||||
@ -318,7 +318,7 @@ defmodule CanneryWeb.ContainerLiveTest do
|
|||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ type_name
|
assert html =~ type_name
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -157,7 +157,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
|> follow_redirect(conn, ~p"/ammo")
|
|> follow_redirect(conn, ~p"/ammo")
|
||||||
|
|
||||||
assert html =~ "Ammo added successfully"
|
assert html =~ "Ammo added successfully"
|
||||||
assert html =~ "\n42\n"
|
assert html =~ " 42\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "saves multiple new packs", %{conn: conn, current_user: current_user} do
|
test "saves multiple new packs", %{conn: conn, current_user: current_user} do
|
||||||
@ -220,7 +220,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
|> follow_redirect(conn, ~p"/ammo")
|
|> follow_redirect(conn, ~p"/ammo")
|
||||||
|
|
||||||
assert html =~ "Ammo updated successfully"
|
assert html =~ "Ammo updated successfully"
|
||||||
assert html =~ "\n43\n"
|
assert html =~ " 43\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "clones pack in listing", %{conn: conn, pack: pack} do
|
test "clones pack in listing", %{conn: conn, pack: pack} do
|
||||||
@ -242,7 +242,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
|> follow_redirect(conn, ~p"/ammo")
|
|> follow_redirect(conn, ~p"/ammo")
|
||||||
|
|
||||||
assert html =~ "Ammo added successfully"
|
assert html =~ "Ammo added successfully"
|
||||||
assert html =~ "\n42\n"
|
assert html =~ " 42\n"
|
||||||
assert html =~ "$#{display_currency(120.5)}"
|
assert html =~ "$#{display_currency(120.5)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
|> follow_redirect(conn, ~p"/ammo")
|
|> follow_redirect(conn, ~p"/ammo")
|
||||||
|
|
||||||
assert html =~ "Ammo added successfully"
|
assert html =~ "Ammo added successfully"
|
||||||
assert html =~ "\n43\n"
|
assert html =~ " 43\n"
|
||||||
assert html =~ "$#{display_currency(120.5)}"
|
assert html =~ "$#{display_currency(120.5)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
assert html =~ "Show used"
|
assert html =~ "Show used"
|
||||||
refute html =~ "$#{display_currency(50.00)}"
|
refute html =~ "$#{display_currency(50.00)}"
|
||||||
percentage = pack |> Ammo.get_percentage_remaining(current_user)
|
percentage = pack |> Ammo.get_percentage_remaining(current_user)
|
||||||
refute html =~ "\n#{"#{percentage}%"}\n"
|
refute html =~ " #{"#{percentage}%"}\n"
|
||||||
|
|
||||||
html =
|
html =
|
||||||
show_live
|
show_live
|
||||||
@ -343,7 +343,7 @@ defmodule CanneryWeb.PackLiveTest do
|
|||||||
|
|
||||||
assert html =~ "$#{display_currency(50.00)}"
|
assert html =~ "$#{display_currency(50.00)}"
|
||||||
percentage = pack |> Ammo.get_percentage_remaining(current_user)
|
percentage = pack |> Ammo.get_percentage_remaining(current_user)
|
||||||
assert html =~ "\n#{"#{percentage}%"}\n"
|
assert html =~ " #{"#{percentage}%"}\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -261,9 +261,9 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
assert html =~ "Total ever rounds"
|
assert html =~ "Total ever rounds"
|
||||||
assert html =~ "Used packs"
|
assert html =~ "Used packs"
|
||||||
assert html =~ "Total ever packs"
|
assert html =~ "Total ever packs"
|
||||||
assert html =~ "\n20\n"
|
assert html =~ "20\n"
|
||||||
assert html =~ "\n0\n"
|
assert html =~ " 0\n"
|
||||||
assert html =~ "\n1\n"
|
assert html =~ " 1\n"
|
||||||
|
|
||||||
shot_record_fixture(%{count: 5}, current_user, pack)
|
shot_record_fixture(%{count: 5}, current_user, pack)
|
||||||
{:ok, index_live, _html} = live(conn, ~p"/catalog")
|
{:ok, index_live, _html} = live(conn, ~p"/catalog")
|
||||||
@ -273,8 +273,8 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ "\n15\n"
|
assert html =~ " 15\n"
|
||||||
assert html =~ "\n5\n"
|
assert html =~ " 5\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
} do
|
} do
|
||||||
{:ok, _show_live, html} = live(conn, ~p"/type/#{type}")
|
{:ok, _show_live, html} = live(conn, ~p"/type/#{type}")
|
||||||
assert html =~ type_name
|
assert html =~ type_name
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
assert html =~ container_name
|
assert html =~ container_name
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_table-label"}]/)
|
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_table-label"}]/)
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
assert html =~ container_name
|
assert html =~ container_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -350,14 +350,14 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
%{conn: conn, type: type, container: %{name: container_name}} do
|
%{conn: conn, type: type, container: %{name: container_name}} do
|
||||||
{:ok, show_live, html} = live(conn, ~p"/type/#{type}")
|
{:ok, show_live, html} = live(conn, ~p"/type/#{type}")
|
||||||
assert html =~ "Show used"
|
assert html =~ "Show used"
|
||||||
refute html =~ "\n20\n"
|
refute html =~ " 20\n"
|
||||||
|
|
||||||
html =
|
html =
|
||||||
show_live
|
show_live
|
||||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
assert html =~ "Empty"
|
assert html =~ "Empty"
|
||||||
assert html =~ container_name
|
assert html =~ container_name
|
||||||
end
|
end
|
||||||
@ -372,14 +372,14 @@ defmodule CanneryWeb.TypeLiveTest do
|
|||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ "Show used"
|
assert html =~ "Show used"
|
||||||
refute html =~ "\n20\n"
|
refute html =~ " 20\n"
|
||||||
|
|
||||||
html =
|
html =
|
||||||
show_live
|
show_live
|
||||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_show_used-label"}]/)
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert html =~ "\n20\n"
|
assert html =~ " 20\n"
|
||||||
assert html =~ "Empty"
|
assert html =~ "Empty"
|
||||||
assert html =~ container_name
|
assert html =~ container_name
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user