Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
remove no-op coalesce calls (#4015)
ruslandoga350d42fb955c
diff --git a/lib/plausible/stats/imported.ex b/lib/plausible/stats/imported.exindex 52f7f92eb6..0346751ad3 100644--- a/lib/plausible/stats/imported.ex+++ b/lib/plausible/stats/imported.ex@@ -457,29 +457,19 @@ defmodule Plausible.Stats.Imported dodefp select_joined_metrics(q, [:visits | rest]) doq- |> select_merge([s, i], %{- :visits => fragment("? + ?", s.visits, i.visits)- })+ |> select_merge([s, i], %{visits: s.visits + i.visits})|> select_joined_metrics(rest)enddefp select_joined_metrics(q, [:visitors | rest]) doq- |> select_merge([s, i], %{- :visitors =>- selected_as(- fragment("coalesce(?, 0) + coalesce(?, 0)", s.visitors, i.visitors),- :visitors- )- })+ |> select_merge([s, i], %{visitors: selected_as(s.visitors + i.visitors, :visitors)})|> select_joined_metrics(rest)enddefp select_joined_metrics(q, [:pageviews | rest]) doq- |> select_merge([s, i], %{- pageviews: fragment("coalesce(?, 0) + coalesce(?, 0)", s.pageviews, i.pageviews)- })+ |> select_merge([s, i], %{pageviews: s.pageviews + i.pageviews})|> select_joined_metrics(rest)end@@ -488,13 +478,7 @@ defmodule Plausible.Stats.Imported do|> select_merge([s, i], %{views_per_visit:fragment(- """- if(- coalesce(?, 0) + coalesce(?, 0) > 0,- round((? + ? * coalesce(?, 0)) / (coalesce(?, 0) + coalesce(?, 0)), 2),- 0- )- """,+ "if(? + ? > 0, round((? + ? * ?) / (? + ?), 2), 0)",s.__internal_visits,i.__internal_visits,i.pageviews,@@ -512,13 +496,7 @@ defmodule Plausible.Stats.Imported do|> select_merge([s, i], %{bounce_rate:fragment(- """- if(- coalesce(?, 0) + coalesce(?, 0) > 0,- round(100 * (coalesce(?, 0) + coalesce((? * ? / 100), 0)) / (coalesce(?, 0) + coalesce(?, 0))),- 0- )- """,+ "if(? + ? > 0, round(100 * (? + (? * ? / 100)) / (? + ?)), 0)",s.__internal_visits,i.__internal_visits,i.bounces,@@ -567,7 +545,7 @@ defmodule Plausible.Stats.Imported doenddefp apply_order_by(q, [:visitors | rest]) do- order_by(q, [s, i], desc: fragment("coalesce(?, 0) + coalesce(?, 0)", s.visitors, i.visitors))+ order_by(q, [s, i], desc: s.visitors + i.visitors)|> apply_order_by(rest)end