diff --git a/assets/js/dashboard/api.js b/assets/js/dashboard/api.js index 6aaae36339f3..a9ff924e445f 100644 --- a/assets/js/dashboard/api.js +++ b/assets/js/dashboard/api.js @@ -38,7 +38,6 @@ export function serializeQuery(query, extraQuery = []) { if (query.from) { queryObj.from = formatISO(query.from) } if (query.to) { queryObj.to = formatISO(query.to) } if (query.filters) { queryObj.filters = serializeApiFilters(query.filters) } - if (query.experimental_session_count) { queryObj.experimental_session_count = query.experimental_session_count } if (query.with_imported) { queryObj.with_imported = query.with_imported } if (SHARED_LINK_AUTH) { queryObj.auth = SHARED_LINK_AUTH } diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.js index 4a61841e9873..0335f510ff4e 100644 --- a/assets/js/dashboard/query.js +++ b/assets/js/dashboard/query.js @@ -42,7 +42,6 @@ export function parseQuery(querystring, site) { to: q.get('to') ? dayjs.utc(q.get('to')) : undefined, match_day_of_week: matchDayOfWeek == 'true', with_imported: q.get('with_imported') ? q.get('with_imported') === 'true' : true, - experimental_session_count: q.get('experimental_session_count'), filters: parseJsonUrl(q.get('filters'), []), labels: parseJsonUrl(q.get('labels'), {}) } diff --git a/lib/plausible/stats/query.ex b/lib/plausible/stats/query.ex index 56568f01fbbb..9d2eb0d66753 100644 --- a/lib/plausible/stats/query.ex +++ b/lib/plausible/stats/query.ex @@ -10,7 +10,6 @@ defmodule Plausible.Stats.Query do include_imported: false, skip_imported_reason: nil, now: nil, - experimental_session_count?: false, experimental_reduced_joins?: false, latest_import_end_date: nil, metrics: [], @@ -36,7 +35,6 @@ defmodule Plausible.Stats.Query do query = __MODULE__ |> struct!(now: now, timezone: site.timezone) - |> put_experimental_session_count(site, params) |> put_experimental_reduced_joins(site, params) |> put_period(site, params) |> put_dimensions(params) @@ -56,7 +54,6 @@ defmodule Plausible.Stats.Query do query = struct!(__MODULE__, Map.to_list(query_data)) |> put_imported_opts(site, %{}) - |> put_experimental_session_count(site, params) |> put_experimental_reduced_joins(site, params) |> struct!(v2: true) @@ -64,18 +61,6 @@ defmodule Plausible.Stats.Query do end end - defp put_experimental_session_count(query, site, params) do - if Map.has_key?(params, "experimental_session_count") do - struct!(query, - experimental_session_count?: Map.get(params, "experimental_session_count") == "true" - ) - else - struct!(query, - experimental_session_count?: FunWithFlags.enabled?(:experimental_session_count, for: site) - ) - end - end - defp put_experimental_reduced_joins(query, site, params) do if Map.has_key?(params, "experimental_reduced_joins") do struct!(query, diff --git a/lib/plausible/stats/sql/expression.ex b/lib/plausible/stats/sql/expression.ex index c4e2c9e3264e..2a0afe9ac9f4 100644 --- a/lib/plausible/stats/sql/expression.ex +++ b/lib/plausible/stats/sql/expression.ex @@ -61,7 +61,7 @@ defmodule Plausible.Stats.SQL.Expression do }) end - def dimension(key, "time:hour", :sessions, %Query{experimental_session_count?: true} = query) do + def dimension(key, "time:hour", :sessions, query) do wrap_expression([s], %{ key => regular_time_slots(query, 3600) }) @@ -75,8 +75,7 @@ defmodule Plausible.Stats.SQL.Expression do # :NOTE: This is not exposed in Query APIv2 def dimension(key, "time:minute", :sessions, %Query{ - period: "30m", - experimental_session_count?: true + period: "30m" }) do wrap_expression([s], %{ key => @@ -96,7 +95,7 @@ defmodule Plausible.Stats.SQL.Expression do end # :NOTE: This is not exposed in Query APIv2 - def dimension(key, "time:minute", :sessions, %Query{experimental_session_count?: true} = query) do + def dimension(key, "time:minute", :sessions, query) do wrap_expression([s], %{ key => regular_time_slots(query, 60) }) diff --git a/lib/plausible/stats/sql/where_builder.ex b/lib/plausible/stats/sql/where_builder.ex index 71bcdad49519..73eeecaeefc7 100644 --- a/lib/plausible/stats/sql/where_builder.ex +++ b/lib/plausible/stats/sql/where_builder.ex @@ -51,7 +51,7 @@ defmodule Plausible.Stats.SQL.WhereBuilder do ) end - defp filter_site_time_range(:sessions, site, %Query{experimental_session_count?: true} = query) do + defp filter_site_time_range(:sessions, site, query) do {first_datetime, last_datetime} = utc_boundaries(query, site) # Counts each _active_ session in time range even if they started before @@ -61,15 +61,6 @@ defmodule Plausible.Stats.SQL.WhereBuilder do ) end - defp filter_site_time_range(:sessions, site, query) do - {first_datetime, last_datetime} = utc_boundaries(query, site) - - dynamic( - [s], - s.site_id == ^site.id and s.start >= ^first_datetime and s.start < ^last_datetime - ) - end - defp add_filter(:events, _query, [:is, "event:name", list]) do dynamic([e], e.name in ^list) end diff --git a/lib/plausible/stats/timeseries.ex b/lib/plausible/stats/timeseries.ex index eafeb79fe5bf..5fc3938ed0b3 100644 --- a/lib/plausible/stats/timeseries.ex +++ b/lib/plausible/stats/timeseries.ex @@ -26,8 +26,7 @@ defmodule Plausible.Stats.Timeseries do dimensions: [time_dimension(query)], order_by: [{time_dimension(query), :asc}], v2: true, - include: %{time_labels: true, imports: query.include.imports}, - experimental_session_count?: true + include: %{time_labels: true, imports: query.include.imports} ) |> QueryOptimizer.optimize() diff --git a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs index 1f7d5b48688a..a873404032db 100644 --- a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs +++ b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs @@ -85,7 +85,7 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do conn = get( conn, - "/api/stats/#{site.domain}/top-stats?period=day&date=2021-01-01&experimental_session_count=true" + "/api/stats/#{site.domain}/top-stats?period=day&date=2021-01-01" ) res = json_response(conn, 200) diff --git a/test/test_helper.exs b/test/test_helper.exs index d9ec1e60a151..60cb5701a9fc 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -11,10 +11,8 @@ Application.ensure_all_started(:double) # Temporary flag to test `experimental_reduced_joins` flag on all tests. if System.get_env("TEST_EXPERIMENTAL_REDUCED_JOINS") == "1" do FunWithFlags.enable(:experimental_reduced_joins) - FunWithFlags.enable(:experimental_session_count) else FunWithFlags.disable(:experimental_reduced_joins) - FunWithFlags.disable(:experimental_session_count) end Ecto.Adapters.SQL.Sandbox.mode(Plausible.Repo, :manual)