Show noref in notification email

pull/453/head
Uku Taht 6 years ago
parent 7f9525e805
commit acce144809

@ -1,25 +1,11 @@
There are currently <%= @current_visitors %> visitors on <%= link(@site.domain, to: "https://" <> @site.domain) %>.
<br />
<br />
<%= if Enum.count(@sources) > 0 do %>
<br />
<br />
The top 3 sources for current visitors:<br />
<table width="100%" cellpadding="0" cellspacing="0" style="max-width: 400px;">
<thead>
<tr>
<th scope="col"><b>Page</b></th>
<th scope="col"><b>Visitors</b></th>
</tr>
</thead>
<tbody>
<%= for %{"name" => source, "count" => visitors} <- @sources do %>
<tr>
<td valign="top"><%= source %></td>
<td valign="top"><%= visitors %></td>
</tr>
<% end %>
</tbody>
</table>
<%= for %{name: source, count: visitors} <- @sources do %>
<%= source %> - <%= visitors %> visitors<br />
<% end %>
<% end %>
<%= if @link do %>

@ -17,7 +17,7 @@ defmodule Plausible.Workers.SpikeNotifier do
for notification <- notifications do
query = Query.from(notification.site.timezone, %{"period" => "realtime"})
current_visitors = clickhouse.current_visitors(notification.site, query)
sources = clickhouse.top_sources(notification.site, query, 3, 1)
sources = clickhouse.top_sources(notification.site, query, 3, 1, true)
notify(notification, current_visitors, sources)
end
end

@ -9,7 +9,7 @@ defmodule Plausible.Workers.SpikeNotifierTest do
insert(:spike_notification, site: site, threshold: 10, recipients: ["jerod@example.com", "uku@example.com"])
clickhouse_stub = stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 5 end)
|> stub(:top_sources, fn _site, _query, _limit, _page -> [] end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
SpikeNotifier.perform(nil, nil, clickhouse_stub)
assert_no_emails_delivered()
@ -20,7 +20,7 @@ defmodule Plausible.Workers.SpikeNotifierTest do
insert(:spike_notification, site: site, threshold: 10, recipients: ["jerod@example.com", "uku@example.com"])
clickhouse_stub = stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|> stub(:top_sources, fn _site, _query, _limit, _page -> [] end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
SpikeNotifier.perform(nil, nil, clickhouse_stub)
assert_email_delivered_with(
@ -38,7 +38,7 @@ defmodule Plausible.Workers.SpikeNotifierTest do
site = insert(:site)
insert(:spike_notification, site: site, threshold: 10, recipients: ["uku@example.com"])
clickhouse_stub = stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|> stub(:top_sources, fn _site, _query, _limit, _page -> [] end)
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
SpikeNotifier.perform(nil, nil, clickhouse_stub)

Loading…
Cancel
Save