mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 17:44:43 +03:00
Fix 'field key does not exist' error (#2674)
This commit is contained in:
parent
0db52ff977
commit
8fcf4d3304
@ -336,12 +336,13 @@ defmodule Plausible.Stats.Breakdown do
|
|||||||
else
|
else
|
||||||
from(
|
from(
|
||||||
e in q,
|
e in q,
|
||||||
inner_lateral_join: meta in fragment("meta")
|
inner_lateral_join: meta in fragment("meta"),
|
||||||
|
as: :meta
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
from(
|
from(
|
||||||
[e, meta] in q,
|
[e, meta: meta] in q,
|
||||||
where: meta.key == ^prop,
|
where: meta.key == ^prop,
|
||||||
group_by: meta.value,
|
group_by: meta.value,
|
||||||
select_merge: %{^prop => meta.value},
|
select_merge: %{^prop => meta.value},
|
||||||
|
@ -430,6 +430,51 @@ defmodule PlausibleWeb.Api.StatsController.ConversionsTest do
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "Property breakdown with goal and source filter", %{conn: conn, site: site} do
|
||||||
|
populate_stats(site, [
|
||||||
|
build(:pageview, user_id: 1, referrer_source: "Google"),
|
||||||
|
build(:event,
|
||||||
|
user_id: 1,
|
||||||
|
name: "ButtonClick",
|
||||||
|
"meta.key": ["variant"],
|
||||||
|
"meta.value": ["A"]
|
||||||
|
),
|
||||||
|
build(:pageview, user_id: 2, referrer_source: "Google"),
|
||||||
|
build(:pageview, user_id: 3, referrer_source: "ignore"),
|
||||||
|
build(:event,
|
||||||
|
user_id: 3,
|
||||||
|
name: "ButtonClick",
|
||||||
|
"meta.key": ["variant"],
|
||||||
|
"meta.value": ["B"]
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
|
insert(:goal, %{domain: site.domain, event_name: "ButtonClick"})
|
||||||
|
|
||||||
|
filters =
|
||||||
|
Jason.encode!(%{
|
||||||
|
goal: "ButtonClick",
|
||||||
|
source: "Google"
|
||||||
|
})
|
||||||
|
|
||||||
|
prop_key = "variant"
|
||||||
|
|
||||||
|
conn =
|
||||||
|
get(
|
||||||
|
conn,
|
||||||
|
"/api/stats/#{site.domain}/property/#{prop_key}?period=day&filters=#{filters}"
|
||||||
|
)
|
||||||
|
|
||||||
|
assert json_response(conn, 200) == [
|
||||||
|
%{
|
||||||
|
"name" => "A",
|
||||||
|
"unique_conversions" => 1,
|
||||||
|
"total_conversions" => 1,
|
||||||
|
"conversion_rate" => 50.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/stats/:domain/conversions - with glob goals" do
|
describe "GET /api/stats/:domain/conversions - with glob goals" do
|
||||||
|
Loading…
Reference in New Issue
Block a user