mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 10:33:01 +03:00
Fix billing usage section
This commit is contained in:
parent
e8cb4ddefb
commit
06177b84e6
@ -183,8 +183,8 @@ defmodule Plausible.Billing do
|
||||
Enum.reduce(user.sites, {0, 0}, fn site, {pageviews, custom_events} ->
|
||||
usage = Plausible.Stats.Clickhouse.usage(site)
|
||||
|
||||
{pageviews + Map.get(usage, :pageviews, 0),
|
||||
custom_events + Map.get(usage, :custom_events, 0)}
|
||||
{pageviews + Map.get(usage, "pageviews", 0),
|
||||
custom_events + Map.get(usage, "custom_events", 0)}
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -181,13 +181,12 @@ defmodule Plausible.Stats.Clickhouse do
|
||||
from e in "events",
|
||||
where: e.domain == ^site.domain,
|
||||
where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime,
|
||||
group_by: e.name,
|
||||
select: {e.name, fragment("count(*)")}
|
||||
group_by: fragment("name"),
|
||||
select: {
|
||||
fragment("if(? = 'pageview', 'pageviews', 'custom_events') as name", e.name),
|
||||
fragment("count(*)")
|
||||
}
|
||||
)
|
||||
|> Enum.map(fn {ev_name, count} ->
|
||||
ev_name = if ev_name == "pageview", do: :pageviews, else: :custom_events
|
||||
{ev_name, count}
|
||||
end)
|
||||
|> Enum.into(%{})
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user