Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plausible-analytics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
varac-projects
plausible-analytics
Commits
06d0d0ea
Commit
06d0d0ea
authored
3 years ago
by
Uku Taht
Browse files
Options
Downloads
Patches
Plain Diff
Fix over limit email reccommendation
parent
0e3db09f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/workers/check_usage.ex
+1
-1
1 addition, 1 deletion
lib/workers/check_usage.ex
test/workers/check_usage_test.exs
+26
-0
26 additions, 0 deletions
test/workers/check_usage_test.exs
with
27 additions
and
1 deletion
lib/workers/check_usage.ex
+
1
−
1
View file @
06d0d0ea
...
...
@@ -85,7 +85,7 @@ defmodule Plausible.Workers.CheckUsage do
defp
check_regular_subscriber
(
subscriber
,
billing_mod
)
do
case
check_pageview_limit
(
subscriber
,
billing_mod
)
do
{
:over_limit
,
{
last_cycle
,
last_cycle_usage
}}
->
suggested_plan
=
Plausible
.
Billing
.
Plans
.
suggested_plan
(
subscriber
,
last_cycle
)
suggested_plan
=
Plausible
.
Billing
.
Plans
.
suggested_plan
(
subscriber
,
last_cycle
_usage
)
template
=
PlausibleWeb
.
Email
.
over_limit_email
(
...
...
This diff is collapsed.
Click to expand it.
test/workers/check_usage_test.exs
+
26
−
0
View file @
06d0d0ea
...
...
@@ -97,6 +97,32 @@ defmodule Plausible.Workers.CheckUsageTest do
assert
Repo
.
reload
(
user
)
.
grace_period
.
end_date
==
Timex
.
shift
(
Timex
.
today
(),
days:
7
)
end
test
"reccommends a plan to upgrade to"
,
%{
user:
user
}
do
billing_stub
=
Plausible
.
Billing
|>
stub
(
:last_two_billing_months_usage
,
fn
_user
->
{
11_000
,
11_000
}
end
)
|>
stub
(
:last_two_billing_cycles
,
fn
_user
->
{
Date
.
range
(
Timex
.
today
(),
Timex
.
today
()),
Date
.
range
(
Timex
.
today
(),
Timex
.
today
())}
end
)
insert
(
:subscription
,
user:
user
,
paddle_plan_id:
@paddle_id_10k
,
last_bill_date:
Timex
.
shift
(
Timex
.
today
(),
days:
-
1
)
)
CheckUsage
.
perform
(
nil
,
billing_stub
)
assert_delivered_email_matches
(%{
html_body:
html_body
})
# Should find 2 visiors
assert
html_body
=~
~s(Based on that we recommend you select the 100k/mo plan.)
end
describe
"enterprise customers"
do
test
"checks billable pageview usage for enterprise customer, sends usage information to enterprise@plausible.io"
,
%{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment