Improves realtime top stats and conversion rate calculation (#500)

* Fixes goal conversion rate when period is realtime

* Adds unique visitors (30m) to realtime top stats

* Changelog

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
This commit is contained in:
Vignesh Joglekar 2020-12-22 07:54:41 -06:00 committed by GitHub
parent b7827fee6a
commit f776c6bb30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Simple notifications around traffic spikes plausible/analytics#453
- Dark theme option/system setting follow plausible/analytics#467
- "Load More" capability to pages modal plausible/analytics#480
- Unique Visitors (last 30 min) as a top stat in realtime view plausible/analytics#500
- Pinned filter and date selector rows while scrolling plausible/analytics#472
### Changed
@ -33,6 +34,7 @@ All notable changes to this project will be documented in this file.
- Prevent picking dates before site insertion plausible/analtics#446
- Fix overly-sticky from and to in query parameters plausible/analytics#495
- Adds support for single-day date selection plausible/analytics#495
- Goal conversion rate in realtime view is now accurate plausible/analytics#500
### Security
- Do not run the plausible Docker container as root plausible/analytics#362

View File

@ -166,6 +166,7 @@ defmodule Plausible.Stats.Clickhouse do
end
def unique_visitors(site, query) do
query = if query.period == "realtime", do: %Query{query | period: "30m"}, else: query
ClickhouseRepo.one(
from e in base_query_w_sessions(site, query),
select: fragment("uniq(user_id)")

View File

@ -28,6 +28,10 @@ defmodule PlausibleWeb.Api.StatsController do
name: "Current visitors",
count: Stats.current_visitors(site, query)
},
%{
name: "Unique visitors (last 30 min)",
count: Stats.unique_visitors(site, query)
},
%{
name: "Pageviews (last 30 min)",
count: Stats.total_pageviews(site, query)