Skip to content

Commit

Permalink
Refactor: move goals stats code explicitly under Stats.Goals module
Browse files Browse the repository at this point in the history
  • Loading branch information
macobo committed Jan 30, 2025
1 parent dbaf9b3 commit 8f28b28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/plausible/stats/filters/query_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ defmodule Plausible.Stats.Filters.QueryParser do

def preload_goals_and_revenue(site, metrics, filters, dimensions) do
preloaded_goals =
Plausible.Goals.Filters.preload_needed_goals(site, dimensions, filters)
Plausible.Stats.Goals.preload_needed_goals(site, dimensions, filters)

{revenue_warning, revenue_currencies} =
preload_revenue(site, preloaded_goals, metrics, dimensions)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
defmodule Plausible.Goals.Filters do
@moduledoc false
defmodule Plausible.Stats.Goals do
@moduledoc """
Stats code related to filtering and grouping by goals.
"""

import Ecto.Query
import Plausible.Stats.Filters.Utils, only: [page_regex: 1]
Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/stats/imported/sql/where_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ defmodule Plausible.Stats.Imported.SQL.WhereBuilder do
db_field = Plausible.Stats.Filters.without_prefix(dimension)

if db_field == :goal do
Plausible.Goals.Filters.add_filter(query, filter, imported?: true)
Plausible.Stats.Goals.add_filter(query, filter, imported?: true)
else
mapped_db_field = Map.get(@db_field_mappings, db_field, db_field)

Expand Down
2 changes: 1 addition & 1 deletion lib/plausible/stats/sql/where_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ defmodule Plausible.Stats.SQL.WhereBuilder do
end

defp add_filter(:events, query, [_, "event:goal" | _rest] = filter) do
Plausible.Goals.Filters.add_filter(query, filter)
Plausible.Stats.Goals.add_filter(query, filter)
end

defp add_filter(:events, _query, [_, "event:page" | _rest] = filter) do
Expand Down

0 comments on commit 8f28b28

Please sign in to comment.