mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 18:48:06 +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} ->
|
Enum.reduce(user.sites, {0, 0}, fn site, {pageviews, custom_events} ->
|
||||||
usage = Plausible.Stats.Clickhouse.usage(site)
|
usage = Plausible.Stats.Clickhouse.usage(site)
|
||||||
|
|
||||||
{pageviews + Map.get(usage, :pageviews, 0),
|
{pageviews + Map.get(usage, "pageviews", 0),
|
||||||
custom_events + Map.get(usage, :custom_events, 0)}
|
custom_events + Map.get(usage, "custom_events", 0)}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -181,13 +181,12 @@ defmodule Plausible.Stats.Clickhouse do
|
|||||||
from e in "events",
|
from e in "events",
|
||||||
where: e.domain == ^site.domain,
|
where: e.domain == ^site.domain,
|
||||||
where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime,
|
where: e.timestamp >= ^first_datetime and e.timestamp < ^last_datetime,
|
||||||
group_by: e.name,
|
group_by: fragment("name"),
|
||||||
select: {e.name, fragment("count(*)")}
|
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(%{})
|
|> Enum.into(%{})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user