mirror of
https://github.com/plausible/analytics.git
synced 2024-12-27 19:47:26 +03:00
d1b703f007
* Get stats from clickhosue * Pull stats from clickhouse * Use correct Query namespace * Use Clickhouse in unit tests * Use Clickhouse in stats controller tests * Use fixtures for unit tests * Add Clickhouse to travis * Use Clickhouse session store for sessions * Add garbage collection to session store * Reload session state from Clickhouse on server restart * Query from sessions table * Trap exits in event write buffer * Run hydration without starting the whole app * Make session length 30 minutes * Revert changes to fingerprint schema * Remove clickhouse from fingerprint sessions * Flush buffers before shutdown * Use old stats when merging * Remove old session schema * Fix tests with CH sessions * Add has_pageviews? to Stats
37 lines
1.3 KiB
Elixir
37 lines
1.3 KiB
Elixir
defmodule PlausibleWeb.Api.StatsController.ConversionsTest do
|
|
use PlausibleWeb.ConnCase
|
|
import Plausible.TestUtils
|
|
|
|
describe "GET /api/stats/:domain/conversions" do
|
|
setup [:create_user, :log_in, :create_site]
|
|
|
|
test "returns mixed conversions in ordered by count", %{conn: conn, site: site} do
|
|
insert(:goal, %{domain: site.domain, page_path: "/register"})
|
|
insert(:goal, %{domain: site.domain, event_name: "Signup"})
|
|
|
|
conn = get(conn, "/api/stats/#{site.domain}/conversions?period=day&date=2019-01-01")
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{"name" => "Signup", "count" => 3},
|
|
%{"name" => "Visit /register", "count" => 2}
|
|
]
|
|
end
|
|
end
|
|
|
|
describe "GET /api/stats/:domain/conversions - with goal filter" do
|
|
setup [:create_user, :log_in, :create_site]
|
|
|
|
test "returns only the conversion tha is filtered for", %{conn: conn, site: site} do
|
|
insert(:goal, %{domain: site.domain, page_path: "/register"})
|
|
insert(:goal, %{domain: site.domain, event_name: "Signup"})
|
|
|
|
filters = Jason.encode!(%{goal: "Signup"})
|
|
conn = get(conn, "/api/stats/#{site.domain}/conversions?period=day&date=2019-01-01&filters=#{filters}")
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{"name" => "Signup", "count" => 3},
|
|
]
|
|
end
|
|
end
|
|
end
|