mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Expunge improper schema use of NaiveDateTime (#91)
This commit is contained in:
parent
24b22f78be
commit
0f6a773286
52 changed files with 70 additions and 73 deletions
|
@ -27,7 +27,7 @@ defmodule Philomena.Adverts.Advert do
|
|||
field :start_time, :string, virtual: true
|
||||
field :finish_time, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule Philomena.ArtistLinks.ArtistLink do
|
|||
field :next_check_at, :utc_datetime
|
||||
field :contacted_at, :utc_datetime
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule Philomena.Badges.Award do
|
|||
field :reason, :string
|
||||
field :badge_name, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -13,7 +13,7 @@ defmodule Philomena.Badges.Badge do
|
|||
field :removed_image, :string, virtual: true
|
||||
field :image_mime_type, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule Philomena.Bans.Fingerprint do
|
|||
|
||||
field :until, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule Philomena.Bans.Subnet do
|
|||
|
||||
field :until, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule Philomena.Bans.User do
|
|||
field :username, :string, virtual: true
|
||||
field :until, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule Philomena.Channels.Channel do
|
|||
field :remote_stream_id, :integer
|
||||
field :thumbnail_url, :string, default: ""
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule Philomena.Comments.Comment do
|
|||
field :destroyed_content, :boolean, default: false
|
||||
field :name_at_post_time, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule Philomena.Commissions.Commission do
|
|||
field :will_not_create, :string
|
||||
field :commission_items_count, :integer, default: 0
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.Commissions.Item do
|
|||
field :base_price, :decimal
|
||||
field :add_ons, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -22,7 +22,7 @@ defmodule Philomena.Conversations.Conversation do
|
|||
field :last_message_at, :utc_datetime
|
||||
field :recipient, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -11,7 +11,7 @@ defmodule Philomena.Conversations.Message do
|
|||
|
||||
field :body, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule Philomena.DnpEntries.DnpEntry do
|
|||
field :instructions, :string, default: ""
|
||||
field :feedback, :string, default: ""
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.Donations.Donation do
|
|||
field :receipt_id, :string
|
||||
field :note, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.DuplicateReports.DuplicateReport do
|
|||
field :reason, :string
|
||||
field :state, :string, default: "open"
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule Philomena.Filters.Filter do
|
|||
field :spoilered_tag_list, :string, virtual: true
|
||||
field :hidden_tag_list, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule Philomena.Forums.Forum do
|
|||
field :topic_count, :integer, default: 0
|
||||
field :post_count, :integer, default: 0
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule Philomena.Galleries.Gallery do
|
|||
field :image_count, :integer
|
||||
field :order_position_asc, :boolean
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -11,7 +11,7 @@ defmodule Philomena.ImageFeatures.ImageFeature do
|
|||
belongs_to :image, Image
|
||||
belongs_to :user, User
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -319,7 +319,7 @@ defmodule Philomena.Images do
|
|||
end
|
||||
|
||||
defp tag_change_attributes(attribution, image, tag, added, user) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
user_id =
|
||||
case user do
|
||||
|
@ -482,7 +482,7 @@ defmodule Philomena.Images do
|
|||
|
||||
defp update_first_seen_at(image, time_1, time_2) do
|
||||
min_time =
|
||||
case NaiveDateTime.compare(time_1, time_2) do
|
||||
case DateTime.compare(time_1, time_2) do
|
||||
:gt -> time_2
|
||||
_ -> time_1
|
||||
end
|
||||
|
@ -551,7 +551,7 @@ defmodule Philomena.Images do
|
|||
|> where([t], t.image_id in ^image_ids and t.tag_id in ^removed_tags)
|
||||
|> select([t], [t.image_id, t.tag_id])
|
||||
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
tag_change_attributes = Map.merge(tag_change_attributes, %{created_at: now, updated_at: now})
|
||||
tag_attributes = %{name: "", slug: "", created_at: now, updated_at: now}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ defmodule Philomena.Images.Image do
|
|||
field :tag_editing_allowed, :boolean, default: true
|
||||
field :description_editing_allowed, :boolean, default: true
|
||||
field :commenting_allowed, :boolean, default: true
|
||||
field :first_seen_at, :naive_datetime
|
||||
field :first_seen_at, :utc_datetime
|
||||
field :destroyed_content, :boolean
|
||||
field :hidden_image_key, :string
|
||||
field :scratchpad, :string
|
||||
|
@ -92,7 +92,7 @@ defmodule Philomena.Images.Image do
|
|||
field :uploaded_image, :string, virtual: true
|
||||
field :removed_image, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
def interaction_data(image) do
|
||||
|
@ -112,7 +112,7 @@ defmodule Philomena.Images.Image do
|
|||
end
|
||||
|
||||
def creation_changeset(image, attrs, attribution) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
image
|
||||
|> cast(attrs, [:anonymous, :source_url, :description])
|
||||
|
|
|
@ -72,7 +72,7 @@ defmodule Philomena.Interactions do
|
|||
end
|
||||
|
||||
def migrate_interactions(source, target) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
source = Repo.preload(source, [:hiders, :favers, :upvoters, :downvoters])
|
||||
|
||||
new_hides = Enum.map(source.hiders, &%{image_id: target.id, user_id: &1.id, created_at: now})
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule Philomena.ModNotes.ModNote do
|
|||
|
||||
field :notable, :any, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.Notifications.Notification do
|
|||
field :actor, :any, virtual: true
|
||||
field :actor_child, :any, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -41,7 +41,7 @@ defmodule Philomena.PollVotes do
|
|||
|
||||
"""
|
||||
def create_poll_votes(user, poll, attrs) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
poll_votes = filter_options(user, poll, now, attrs)
|
||||
|
||||
Multi.new()
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule Philomena.Polls.Poll do
|
|||
field :deletion_reason, :string, default: ""
|
||||
field :until, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -24,7 +24,7 @@ defmodule Philomena.Posts.Post do
|
|||
field :destroyed_content, :boolean, default: false
|
||||
field :name_at_post_time, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule Philomena.Reports.Report do
|
|||
field :reportable, :any, virtual: true
|
||||
field :category, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Philomena.Roles.Role do
|
|||
field :resource_id, :integer
|
||||
field :resource_type, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -19,7 +19,7 @@ defmodule Philomena.SiteNotices.SiteNotice do
|
|||
field :start_time, :string, virtual: true
|
||||
field :finish_time, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule Philomena.SourceChanges.SourceChange do
|
|||
|
||||
field :source_url, :string, source: :new_value
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Philomena.StaticPages.StaticPage do
|
|||
field :slug, :string
|
||||
field :body, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule Philomena.StaticPages.Version do
|
|||
|
||||
field :difference, :any, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.TagChanges do
|
|||
# TODO: this is substantially similar to Images.batch_update/4.
|
||||
# Perhaps it should be extracted.
|
||||
def mass_revert(ids, attributes) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
tag_change_attributes = Map.merge(attributes, %{created_at: now, updated_at: now})
|
||||
tag_attributes = %{name: "", slug: "", created_at: now, updated_at: now}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule Philomena.TagChanges.TagChange do
|
|||
field :added, :boolean
|
||||
field :tag_name_cache, :string, default: ""
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -90,7 +90,7 @@ defmodule Philomena.Tags.Tag do
|
|||
|
||||
field :implied_tag_list, :string, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -32,7 +32,7 @@ defmodule Philomena.Topics.Topic do
|
|||
field :anonymous, :boolean, default: false
|
||||
field :hidden_from_users, :boolean, default: false
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -10,7 +10,7 @@ defmodule Philomena.UserFingerprints.UserFingerprint do
|
|||
field :fingerprint, :string
|
||||
field :uses, :integer, default: 0
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -10,7 +10,7 @@ defmodule Philomena.UserIps.UserIp do
|
|||
field :ip, EctoNetwork.INET
|
||||
field :uses, :integer, default: 0
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -8,7 +8,7 @@ defmodule Philomena.UserNameChanges.UserNameChange do
|
|||
belongs_to :user, User
|
||||
field :name, :string
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -8,7 +8,7 @@ defmodule Philomena.UserWhitelists.UserWhitelist do
|
|||
belongs_to :user, User
|
||||
|
||||
field :reason, :string
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc false
|
||||
|
|
|
@ -321,8 +321,8 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
|
|||
|
||||
# Edit their username
|
||||
def can?(%User{id: id}, :change_username, %User{id: id} = user) do
|
||||
time_ago = NaiveDateTime.utc_now() |> NaiveDateTime.add(-1 * 60 * 60 * 24 * 90)
|
||||
NaiveDateTime.diff(user.last_renamed_at, time_ago) < 0
|
||||
time_ago = DateTime.utc_now() |> DateTime.add(-1 * 60 * 60 * 24 * 90)
|
||||
DateTime.diff(user.last_renamed_at, time_ago) < 0
|
||||
end
|
||||
|
||||
# View conversations they are involved in
|
||||
|
|
|
@ -48,12 +48,12 @@ defmodule Philomena.Users.User do
|
|||
field :password, :string, virtual: true
|
||||
field :encrypted_password, :string
|
||||
field :hashed_password, :string, source: :encrypted_password
|
||||
field :confirmed_at, :naive_datetime
|
||||
field :confirmed_at, :utc_datetime
|
||||
field :otp_required_for_login, :boolean
|
||||
field :authentication_token, :string
|
||||
field :failed_attempts, :integer
|
||||
# field :unlock_token, :string
|
||||
field :locked_at, :naive_datetime
|
||||
field :locked_at, :utc_datetime
|
||||
field :encrypted_otp_secret, :string
|
||||
field :encrypted_otp_secret_iv, :string
|
||||
field :encrypted_otp_secret_salt, :string
|
||||
|
@ -111,9 +111,9 @@ defmodule Philomena.Users.User do
|
|||
field :watched_tag_list, :string, virtual: true
|
||||
|
||||
# Other stuff
|
||||
field :last_donation_at, :naive_datetime
|
||||
field :last_renamed_at, :naive_datetime
|
||||
field :deleted_at, :naive_datetime
|
||||
field :last_donation_at, :utc_datetime
|
||||
field :last_renamed_at, :utc_datetime
|
||||
field :deleted_at, :utc_datetime
|
||||
field :scratchpad, :string
|
||||
field :secondary_role, :string
|
||||
field :hide_default_role, :boolean, default: false
|
||||
|
@ -130,7 +130,7 @@ defmodule Philomena.Users.User do
|
|||
# For mod stuff
|
||||
field :role_map, :any, virtual: true
|
||||
|
||||
timestamps(inserted_at: :created_at)
|
||||
timestamps(inserted_at: :created_at, type: :utc_datetime)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
@ -212,7 +212,7 @@ defmodule Philomena.Users.User do
|
|||
Confirms the account by setting `confirmed_at`.
|
||||
"""
|
||||
def confirm_changeset(user) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
change(user, confirmed_at: now)
|
||||
end
|
||||
|
||||
|
@ -256,7 +256,7 @@ defmodule Philomena.Users.User do
|
|||
end
|
||||
|
||||
def lock_changeset(user) do
|
||||
locked_at = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
locked_at = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
change(user, locked_at: locked_at)
|
||||
end
|
||||
|
@ -353,7 +353,7 @@ defmodule Philomena.Users.User do
|
|||
end
|
||||
|
||||
def name_changeset(user, attrs) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
user
|
||||
|> cast(attrs, [:name])
|
||||
|
@ -403,7 +403,7 @@ defmodule Philomena.Users.User do
|
|||
end
|
||||
|
||||
def deactivate_changeset(user, moderator) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
change(user, deleted_at: now, deleted_by_user_id: moderator.id)
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@ defmodule PhilomenaWeb.AdvertUpdater do
|
|||
# Read impression counts from mailbox
|
||||
{impressions, clicks} = receive_all()
|
||||
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
# Create insert statements for Ecto
|
||||
impressions = Enum.map(impressions, &impressions_insert_all(&1, now))
|
||||
|
|
|
@ -46,7 +46,7 @@ defmodule PhilomenaWeb.StatsUpdater do
|
|||
images_in_galleries: images_in_galleries
|
||||
)
|
||||
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
|
||||
static_page = %{
|
||||
title: "Statistics",
|
||||
|
@ -139,7 +139,7 @@ defmodule PhilomenaWeb.StatsUpdater do
|
|||
|
||||
response_time =
|
||||
closed_reports
|
||||
|> Enum.reduce(0, &(&2 + NaiveDateTime.diff(&1.updated_at, &1.created_at, :second)))
|
||||
|> Enum.reduce(0, &(&2 + DateTime.diff(&1.updated_at, &1.created_at, :second)))
|
||||
|> Kernel./(safe_length(closed_reports) * 3600)
|
||||
|> trunc()
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</a>
|
||||
]]>
|
||||
</description>
|
||||
<pubDate><%= NaiveDateTime.to_iso8601(image.created_at) %></pubDate>
|
||||
<pubDate><%= DateTime.to_iso8601(image.created_at) %></pubDate>
|
||||
<link><%= Routes.image_url(@conn, :show, image) %></link>
|
||||
<guid><%= Routes.image_url(@conn, :show, image) %></guid>
|
||||
</item>
|
||||
|
|
|
@ -208,7 +208,7 @@ defmodule PhilomenaWeb.UserAuth do
|
|||
defp signed_in_path(_conn), do: "/"
|
||||
|
||||
defp update_usages(conn, user) do
|
||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
||||
now = DateTime.utc_now() |> DateTime.truncate(:second)
|
||||
conn = fetch_cookies(conn)
|
||||
|
||||
UserIpUpdater.cast(user.id, conn.remote_ip, now)
|
||||
|
|
|
@ -31,10 +31,9 @@ defmodule PhilomenaWeb.AppView do
|
|||
}
|
||||
|
||||
def pretty_time(time) do
|
||||
now = NaiveDateTime.utc_now()
|
||||
seconds = NaiveDateTime.diff(now, time, :second)
|
||||
now = DateTime.utc_now()
|
||||
seconds = DateTime.diff(now, time, :second)
|
||||
relation = if seconds < 0, do: "from now", else: "ago"
|
||||
time = time |> DateTime.from_naive!("Etc/UTC")
|
||||
|
||||
words = distance_of_time_in_words(now, time)
|
||||
|
||||
|
@ -45,7 +44,7 @@ defmodule PhilomenaWeb.AppView do
|
|||
end
|
||||
|
||||
def distance_of_time_in_words(time_2, time_1) do
|
||||
seconds = abs(NaiveDateTime.diff(time_2, time_1, :second))
|
||||
seconds = abs(DateTime.diff(time_2, time_1, :second))
|
||||
minutes = div(seconds, 60)
|
||||
hours = div(minutes, 60)
|
||||
days = div(hours, 24)
|
||||
|
|
|
@ -2,6 +2,6 @@ defmodule PhilomenaWeb.BanView do
|
|||
use PhilomenaWeb, :view
|
||||
|
||||
def active?(ban) do
|
||||
ban.enabled and NaiveDateTime.diff(ban.valid_until, NaiveDateTime.utc_now()) > 0
|
||||
ban.enabled and DateTime.diff(ban.valid_until, DateTime.utc_now()) > 0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -124,8 +124,6 @@ defmodule PhilomenaWeb.ImageView do
|
|||
end
|
||||
|
||||
def image_container_data(conn, image, size) do
|
||||
time = DateTime.from_naive!(image.created_at, "Etc/UTC")
|
||||
|
||||
[
|
||||
image_id: image.id,
|
||||
image_tags: Jason.encode!(Enum.map(image.tags, & &1.id)),
|
||||
|
@ -137,7 +135,7 @@ defmodule PhilomenaWeb.ImageView do
|
|||
upvotes: image.upvotes_count,
|
||||
downvotes: image.downvotes_count,
|
||||
comment_count: image.comments_count,
|
||||
created_at: DateTime.to_iso8601(time),
|
||||
created_at: DateTime.to_iso8601(image.created_at),
|
||||
source_url: image.source_url,
|
||||
uris: Jason.encode!(thumb_urls(image, can?(conn, :show, image))),
|
||||
width: image.image_width,
|
||||
|
|
|
@ -17,8 +17,8 @@ defmodule PhilomenaWeb.Profile.AliasView do
|
|||
def previously_banned?(_user), do: true
|
||||
|
||||
defp younger_than_time_offset?(%{created_at: created_at}, time_offset) do
|
||||
time_ago = NaiveDateTime.utc_now() |> NaiveDateTime.add(-time_offset, :second)
|
||||
time_ago = DateTime.utc_now() |> DateTime.add(-time_offset, :second)
|
||||
|
||||
NaiveDateTime.diff(created_at, time_ago) >= 0
|
||||
DateTime.diff(created_at, time_ago) >= 0
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue