diff --git a/lib/plausible/stats/query.ex b/lib/plausible/stats/query.ex index 1a0befe053..fd657ae759 100644 --- a/lib/plausible/stats/query.ex +++ b/lib/plausible/stats/query.ex @@ -231,14 +231,10 @@ defmodule Plausible.Stats.Query do is_negated = String.contains?(str, "!=") is_list = String.contains?(val, "|") - is_glob = String.contains?(val, "*") cond do - is_list && is_glob -> raise "Not implemented" - is_negated && is_glob -> {key, {:does_not_match, val}} key == "event:goal" -> {key, parse_goal_filter(val)} is_list -> {key, {:member, String.split(val, "|")}} - is_glob -> {key, {:matches, val}} is_negated -> {key, {:is_not, val}} true -> {key, {:is, val}} end diff --git a/test/plausible_web/controllers/api/external_stats_controller/aggregate_test.exs b/test/plausible_web/controllers/api/external_stats_controller/aggregate_test.exs index 01bab4da48..d62586711b 100644 --- a/test/plausible_web/controllers/api/external_stats_controller/aggregate_test.exs +++ b/test/plausible_web/controllers/api/external_stats_controller/aggregate_test.exs @@ -654,35 +654,6 @@ defmodule PlausibleWeb.Api.ExternalStatsController.AggregateTest do } end - test "can filter by page regex", %{conn: conn, site: site} do - populate_stats(site, [ - build(:pageview, - pathname: "/" - ), - build(:pageview, - pathname: "/blog/post1" - ), - build(:pageview, - pathname: "/blog/post1" - ), - build(:pageview, - pathname: "/blog/post2" - ) - ]) - - conn = - get(conn, "/api/v1/stats/aggregate", %{ - "site_id" => site.domain, - "period" => "day", - "metrics" => "visitors", - "filters" => "event:page==/blog/**" - }) - - assert json_response(conn, 200)["results"] == %{ - "visitors" => %{"value" => 3} - } - end - test "filtering by event:name", %{conn: conn, site: site} do populate_stats([ build(:event, diff --git a/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs b/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs index f65557d966..c9bc52a6a6 100644 --- a/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs +++ b/test/plausible_web/controllers/api/external_stats_controller/breakdown_test.exs @@ -1334,65 +1334,5 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest do ] } end - - test "negated glob filter for pages", %{conn: conn, site: site} do - populate_stats(site, [ - build(:pageview, - pathname: "/blog/ignore", - domain: site.domain - ), - build(:pageview, - pathname: "/blog", - domain: site.domain - ), - build(:pageview, - pathname: "/plausible.io", - domain: site.domain - ) - ]) - - conn = - get(conn, "/api/v1/stats/breakdown", %{ - "site_id" => site.domain, - "property" => "event:page", - "filters" => "event:page!=/blog**" - }) - - assert json_response(conn, 200) == %{ - "results" => [ - %{"page" => "/plausible.io", "visitors" => 1} - ] - } - end - - test "negated glob filter for sources", %{conn: conn, site: site} do - populate_stats(site, [ - build(:pageview, - pathname: "/blog/ignore", - referrer_source: "Should not show" - ), - build(:pageview, - pathname: "/blog", - referrer_source: "Should not show" - ), - build(:pageview, - pathname: "/plausible.io", - referrer_source: "Google" - ) - ]) - - conn = - get(conn, "/api/v1/stats/breakdown", %{ - "site_id" => site.domain, - "property" => "visit:source", - "filters" => "event:page!=/blog**" - }) - - assert json_response(conn, 200) == %{ - "results" => [ - %{"source" => "Google", "visitors" => 1} - ] - } - end end end diff --git a/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs b/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs index 928ce839aa..23048bd4bb 100644 --- a/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs +++ b/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs @@ -797,42 +797,5 @@ defmodule PlausibleWeb.Api.ExternalStatsController.TimeseriesTest do assert first == %{"date" => "2021-01-01", "visitors" => 2} assert second == %{"date" => "2021-01-02", "visitors" => 1} end - - test "filter with negated glob for pages", %{conn: conn, site: site} do - populate_stats(site, [ - build(:pageview, - pathname: "/", - timestamp: ~N[2021-01-01 00:00:00] - ), - build(:pageview, - pathname: "/blog", - timestamp: ~N[2021-01-01 00:00:00] - ), - build(:pageview, - pathname: "/plausible.io", - timestamp: ~N[2021-01-02 00:00:00] - ), - build(:pageview, - pathname: "/", - timestamp: ~N[2021-01-02 00:00:00] - ), - build(:pageview, - pathname: "/blog/ignore", - timestamp: ~N[2021-01-02 00:00:00] - ) - ]) - - conn = - get(conn, "/api/v1/stats/timeseries", %{ - "site_id" => site.domain, - "period" => "month", - "date" => "2021-01-01", - "filters" => "event:page!=/blog**" - }) - - %{"results" => [first, second | _rest]} = json_response(conn, 200) - assert first == %{"date" => "2021-01-01", "visitors" => 1} - assert second == %{"date" => "2021-01-02", "visitors" => 2} - end end end