Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Timex.before? and Timex.after? #4552

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/plausible/auth/email_verification.ex
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ defmodule Plausible.Auth.EmailVerification do
@spec expired?(EmailActivationCode.t()) :: boolean()
def expired?(verification) do
expiration_time = NaiveDateTime.shift(NaiveDateTime.utc_now(), hour: -1 * @expiration_hours)
Timex.before?(verification.issued_at, expiration_time)
NaiveDateTime.before?(verification.issued_at, expiration_time)
end
end
2 changes: 1 addition & 1 deletion lib/plausible/billing/feature.ex
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ defmodule Plausible.Billing.Feature.StatsAPI do
subscription? = Plausible.Billing.Subscriptions.active?(user.subscription)

pre_business_tier_account? =
Timex.before?(user.inserted_at, Plausible.Billing.Plans.business_tier_launch())
NaiveDateTime.before?(user.inserted_at, Plausible.Billing.Plans.business_tier_launch())

cond do
!subscription? && unlimited_trial? && pre_business_tier_account? ->
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/billing/qouta/limits.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Plausible.Billing.Quota.Limits do

@spec site_limit(User.t()) :: non_neg_integer() | :unlimited
def site_limit(user) do
if Timex.before?(user.inserted_at, @limit_sites_since) do
if Date.before?(user.inserted_at, @limit_sites_since) do
Copy link
Contributor Author

@ruslandoga ruslandoga Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@limit_sites_since is a date -- ~D[2021-05-05] -- and user.inserted_at is a naive datetime.

Comparisons use "least common denominator" sort-of logic, so Date module needs to be used to compare the two.

:unlimited
else
get_site_limit_from_plan(user)
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/google/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule Plausible.Google.API do

defp needs_to_refresh_token?(%NaiveDateTime{} = expires_at) do
thirty_seconds_ago = DateTime.shift(DateTime.utc_now(), second: 30)
Timex.before?(expires_at, thirty_seconds_ago)
NaiveDateTime.before?(expires_at, thirty_seconds_ago)
end

defp ensure_search_console_property(site) do
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/stats/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Plausible.Stats.Time do
end

defp beginning_of_time(candidate, native_stats_start_at) do
if Timex.after?(native_stats_start_at, candidate) do
if NaiveDateTime.after?(native_stats_start_at, candidate) do
native_stats_start_at
else
candidate
Expand Down