diff --git a/changelog.md b/changelog.md index fa7ee27..4d3b2ff 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# v0.1.20 +- Improve accuracy of timestamps + # v0.1.19 - Add backlinks - Fix visibility issues with multiple users diff --git a/config/config.exs b/config/config.exs index ab2fbcb..be7e25e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -28,9 +28,10 @@ config :memex, MemexWeb.Endpoint, config :memex, Memex.Application, automigrate: false config :memex, :generators, - migration: true, binary_id: true, - sample_binary_id: "11111111-1111-1111-1111-111111111111" + migration: true, + sample_binary_id: "11111111-1111-1111-1111-111111111111", + timestamp_type: :utc_datetime_usec # Configures the mailer # diff --git a/lib/memex/accounts/invite.ex b/lib/memex/accounts/invite.ex index ace1c45..c730fc3 100644 --- a/lib/memex/accounts/invite.ex +++ b/lib/memex/accounts/invite.ex @@ -11,13 +11,13 @@ defmodule Memex.Accounts.Invite do field :name, :string field :token, :string field :uses_left, :integer, default: nil - field :disabled_at, :naive_datetime + field :disabled_at, :utc_datetime_usec belongs_to :created_by, User has_many :users, User - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %__MODULE__{ @@ -25,12 +25,12 @@ defmodule Memex.Accounts.Invite do name: String.t(), token: token(), uses_left: integer() | nil, - disabled_at: NaiveDateTime.t(), + disabled_at: DateTime.t(), created_by: User.t() | nil | Association.NotLoaded.t(), created_by_id: User.id() | nil, users: [User.t()] | Association.NotLoaded.t(), - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type new_invite :: %__MODULE__{} @type id :: UUID.t() diff --git a/lib/memex/accounts/invites.ex b/lib/memex/accounts/invites.ex index 35acf26..6f3e825 100644 --- a/lib/memex/accounts/invites.ex +++ b/lib/memex/accounts/invites.ex @@ -123,7 +123,7 @@ defmodule Memex.Accounts.Invites do end 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}) end diff --git a/lib/memex/accounts/user.ex b/lib/memex/accounts/user.ex index 493fac7..dd182a6 100644 --- a/lib/memex/accounts/user.ex +++ b/lib/memex/accounts/user.ex @@ -21,7 +21,7 @@ defmodule Memex.Accounts.User do field :email, :string field :password, :string, virtual: true field :hashed_password, :string - field :confirmed_at, :naive_datetime + field :confirmed_at, :utc_datetime_usec field :role, Ecto.Enum, values: [:admin, :user], default: :user field :locale, :string @@ -29,7 +29,7 @@ defmodule Memex.Accounts.User do belongs_to :invite, Invite - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %User{ @@ -37,14 +37,14 @@ defmodule Memex.Accounts.User do email: String.t(), password: String.t(), hashed_password: String.t(), - confirmed_at: NaiveDateTime.t(), + confirmed_at: DateTime.t(), role: role(), locale: String.t() | nil, created_invites: [Invite.t()] | Association.NotLoaded.t(), invite: Invite.t() | nil | Association.NotLoaded.t(), invite_id: Invite.id() | nil, - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type new_user :: %User{} @type id :: UUID.t() @@ -166,7 +166,7 @@ defmodule Memex.Accounts.User do """ @spec confirm_changeset(t() | changeset()) :: changeset() 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) end diff --git a/lib/memex/accounts/user_token.ex b/lib/memex/accounts/user_token.ex index dc45e1c..e1f21de 100644 --- a/lib/memex/accounts/user_token.ex +++ b/lib/memex/accounts/user_token.ex @@ -32,7 +32,7 @@ defmodule Memex.Accounts.UserToken do sent_to: String.t(), user: User.t() | Association.NotLoaded.t(), user_id: User.id() | nil, - inserted_at: NaiveDateTime.t() + inserted_at: DateTime.t() } @type new_user_token :: %__MODULE__{} @type id :: UUID.t() diff --git a/lib/memex/contexts/context.ex b/lib/memex/contexts/context.ex index 18e9665..9a506f9 100644 --- a/lib/memex/contexts/context.ex +++ b/lib/memex/contexts/context.ex @@ -25,7 +25,7 @@ defmodule Memex.Contexts.Context do field :user_id, :binary_id - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %__MODULE__{ @@ -35,8 +35,8 @@ defmodule Memex.Contexts.Context do tags_string: String.t() | nil, visibility: :public | :private | :unlisted, user_id: User.id(), - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type id :: UUID.t() @type slug :: String.t() diff --git a/lib/memex/notes/note.ex b/lib/memex/notes/note.ex index e4f8392..737761e 100644 --- a/lib/memex/notes/note.ex +++ b/lib/memex/notes/note.ex @@ -24,7 +24,7 @@ defmodule Memex.Notes.Note do field :user_id, :binary_id - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %__MODULE__{ @@ -34,8 +34,8 @@ defmodule Memex.Notes.Note do tags_string: String.t() | nil, visibility: :public | :private | :unlisted, user_id: User.id(), - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type id :: UUID.t() @type slug :: String.t() diff --git a/lib/memex/pipelines/pipeline.ex b/lib/memex/pipelines/pipeline.ex index c90a7cf..47da10f 100644 --- a/lib/memex/pipelines/pipeline.ex +++ b/lib/memex/pipelines/pipeline.ex @@ -28,7 +28,7 @@ defmodule Memex.Pipelines.Pipeline do has_many :steps, Step, preload_order: [asc: :position] - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %__MODULE__{ @@ -38,8 +38,8 @@ defmodule Memex.Pipelines.Pipeline do tags_string: String.t() | nil, visibility: :public | :private | :unlisted, user_id: User.id(), - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type id :: UUID.t() @type slug :: String.t() diff --git a/lib/memex/pipelines/step.ex b/lib/memex/pipelines/step.ex index c9328f2..e67507a 100644 --- a/lib/memex/pipelines/step.ex +++ b/lib/memex/pipelines/step.ex @@ -22,7 +22,7 @@ defmodule Memex.Pipelines.Steps.Step do belongs_to :pipeline, Pipeline field :user_id, :binary_id - timestamps() + timestamps(type: :utc_datetime_usec) end @type t :: %__MODULE__{ @@ -32,8 +32,8 @@ defmodule Memex.Pipelines.Steps.Step do pipeline: Pipeline.t() | Ecto.Association.NotLoaded.t(), pipeline_id: Pipeline.id(), user_id: User.id(), - inserted_at: NaiveDateTime.t(), - updated_at: NaiveDateTime.t() + inserted_at: DateTime.t(), + updated_at: DateTime.t() } @type id :: UUID.t() @type changeset :: Changeset.t(t()) diff --git a/lib/memex_web/components/core_components.ex b/lib/memex_web/components/core_components.ex index 27a52e6..19ec45f 100644 --- a/lib/memex_web/components/core_components.ex +++ b/lib/memex_web/components/core_components.ex @@ -89,14 +89,14 @@ defmodule MemexWeb.CoreComponents do attr :datetime, :any, required: true, doc: "A `DateTime` struct or nil" @doc """ - Phoenix.Component for a