diff --git a/lib/microwaveprop_web/live/contact_live/index.ex b/lib/microwaveprop_web/live/contact_live/index.ex index 268868c3..8ecf46c8 100644 --- a/lib/microwaveprop_web/live/contact_live/index.ex +++ b/lib/microwaveprop_web/live/contact_live/index.ex @@ -70,17 +70,20 @@ defmodule MicrowavepropWeb.ContactLive.Index do socket |> assign(:page_title, "Contacts") |> assign(:total_contacts, total) - |> assign(:monthly_bars, monthly_bars(scope)) + |> assign(:monthly_bars, monthly_bars()) |> assign(:chart_baseline, @chart_baseline) |> assign(:chart_bar_width, @chart_bar_width) |> assign(:visible_fields, visible_fields_for(scope)) |> assign(:data_provider, {__MODULE__, :visible_query_provider, [scope_token(scope)]})} end - defp monthly_bars(scope) do + # Counts every contact in the corpus regardless of viewer scope — + # the chart is a public-facing seasonal summary, not a personal + # view, so private contacts roll into the per-month totals like + # any other. + defp monthly_bars do by_month = - scope - |> visible_query() + Contact |> where([c], not is_nil(c.qso_timestamp)) |> group_by([c], fragment("EXTRACT(MONTH FROM ?)::int", c.qso_timestamp)) |> select([c], {fragment("EXTRACT(MONTH FROM ?)::int", c.qso_timestamp), count(c.id)})