mirror of
https://github.com/plausible/analytics.git
synced 2024-11-22 10:43:38 +03:00
rm Timex.diff/3 (#4695)
This commit is contained in:
parent
13ad279820
commit
40f28ed151
@ -82,7 +82,7 @@ defmodule Plausible.Auth.GracePeriod do
|
||||
def active?(user_or_team)
|
||||
|
||||
def active?(%{grace_period: %__MODULE__{end_date: %Date{} = end_date}}) do
|
||||
Timex.diff(end_date, Date.utc_today(), :days) >= 0
|
||||
Date.diff(end_date, Date.utc_today()) >= 0
|
||||
end
|
||||
|
||||
def active?(%{grace_period: %__MODULE__{manual_lock: true}}) do
|
||||
|
@ -106,7 +106,7 @@ defmodule Plausible.Auth.UserAdmin do
|
||||
"ended"
|
||||
|
||||
%{end_date: %Date{} = end_date} ->
|
||||
days_left = Timex.diff(end_date, DateTime.utc_now(), :days)
|
||||
days_left = Date.diff(end_date, Date.utc_today())
|
||||
"#{days_left} days left"
|
||||
end
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ defmodule Plausible.Plugins.API.Token do
|
||||
diff =
|
||||
if token.last_used_at do
|
||||
now = NaiveDateTime.utc_now()
|
||||
Timex.diff(now, token.last_used_at, :minutes)
|
||||
NaiveDateTime.diff(now, token.last_used_at, :minute)
|
||||
end
|
||||
|
||||
cond do
|
||||
|
@ -63,7 +63,7 @@ defmodule Plausible.Plugins.API.Tokens do
|
||||
now = NaiveDateTime.truncate(now, :second)
|
||||
last_used = token.last_used_at
|
||||
|
||||
if is_nil(last_used) or Timex.diff(now, last_used, :minutes) > 5 do
|
||||
if is_nil(last_used) or NaiveDateTime.diff(now, last_used, :minute) > 5 do
|
||||
token
|
||||
|> Ecto.Changeset.change(%{last_used_at: now})
|
||||
|> Repo.update()
|
||||
|
@ -62,7 +62,7 @@ defmodule Plausible.Session.CacheStore do
|
||||
nil
|
||||
|
||||
session ->
|
||||
if Timex.diff(event.timestamp, session.timestamp, :minutes) <= 30 do
|
||||
if NaiveDateTime.diff(event.timestamp, session.timestamp, :minute) <= 30 do
|
||||
session
|
||||
end
|
||||
end
|
||||
@ -93,7 +93,7 @@ defmodule Plausible.Session.CacheStore do
|
||||
exit_page_hostname:
|
||||
if(event.name == "pageview", do: event.hostname, else: session.exit_page_hostname),
|
||||
is_bounce: false,
|
||||
duration: Timex.diff(event.timestamp, session.start, :second) |> abs,
|
||||
duration: NaiveDateTime.diff(event.timestamp, session.start) |> abs,
|
||||
pageviews:
|
||||
if(event.name == "pageview", do: session.pageviews + 1, else: session.pageviews),
|
||||
events: session.events + 1
|
||||
|
@ -45,7 +45,7 @@ defmodule Plausible.Stats.Interval do
|
||||
Timex.diff(last, first, :months) > 0 ->
|
||||
"month"
|
||||
|
||||
Timex.diff(last, first, :days) > 0 ->
|
||||
DateTime.diff(last, first, :day) > 0 ->
|
||||
"day"
|
||||
|
||||
true ->
|
||||
|
@ -85,8 +85,8 @@ defmodule Plausible.Stats.QueryOptimizer do
|
||||
|
||||
defp resolve_time_dimension(first, last) do
|
||||
cond do
|
||||
Timex.diff(last, first, :hours) <= 48 -> "time:hour"
|
||||
Timex.diff(last, first, :days) <= 40 -> "time:day"
|
||||
DateTime.diff(last, first, :hour) <= 48 -> "time:hour"
|
||||
DateTime.diff(last, first, :day) <= 40 -> "time:day"
|
||||
Timex.diff(last, first, :weeks) <= 52 -> "time:week"
|
||||
true -> "time:month"
|
||||
end
|
||||
|
@ -26,7 +26,7 @@ defmodule Plausible.Users do
|
||||
|
||||
@spec trial_days_left(Auth.User.t()) :: integer()
|
||||
def trial_days_left(user) do
|
||||
Timex.diff(user.trial_expiry_date, Date.utc_today(), :days)
|
||||
Date.diff(user.trial_expiry_date, Date.utc_today())
|
||||
end
|
||||
|
||||
@spec update_accept_traffic_until(Auth.User.t()) :: Auth.User.t()
|
||||
|
@ -274,7 +274,7 @@ defmodule PlausibleWeb.Components.Billing.PlanBox do
|
||||
|
||||
trial_active_or_ended_recently? =
|
||||
not invited_user? &&
|
||||
Timex.diff(Date.utc_today(), current_user.trial_expiry_date, :days) <= 10
|
||||
Date.diff(Date.utc_today(), current_user.trial_expiry_date) <= 10
|
||||
|
||||
limit_checking_opts =
|
||||
cond do
|
||||
|
@ -107,7 +107,7 @@ defmodule PlausibleWeb.LayoutView do
|
||||
end
|
||||
|
||||
def grace_period_end(%{grace_period: %{end_date: %Date{} = date}}) do
|
||||
case Timex.diff(date, Date.utc_today(), :days) do
|
||||
case Date.diff(date, Date.utc_today()) do
|
||||
0 -> "today"
|
||||
1 -> "tomorrow"
|
||||
n -> "within #{n} days"
|
||||
|
@ -44,7 +44,7 @@ defmodule Plausible.Workers.SendSiteSetupEmails do
|
||||
for site <- Repo.all(q) do
|
||||
owner = Plausible.Users.with_subscription(site.owner)
|
||||
setup_completed = Plausible.Sites.has_stats?(site)
|
||||
hours_passed = Timex.diff(DateTime.utc_now(), site.inserted_at, :hours)
|
||||
hours_passed = NaiveDateTime.diff(DateTime.utc_now(), site.inserted_at, :hour)
|
||||
|
||||
if !setup_completed && hours_passed > 47 do
|
||||
send_setup_help_email(owner, site)
|
||||
|
@ -20,7 +20,7 @@ defmodule Plausible.Workers.SendTrialNotifications do
|
||||
)
|
||||
|
||||
for user <- users do
|
||||
case Timex.diff(user.trial_expiry_date, Date.utc_today(), :days) do
|
||||
case Date.diff(user.trial_expiry_date, Date.utc_today()) do
|
||||
7 ->
|
||||
if Plausible.Auth.has_active_sites?(user, [:owner]) do
|
||||
send_one_week_reminder(user)
|
||||
|
Loading…
Reference in New Issue
Block a user