From 1c6e9005d16e304e3a5505e728f4b349243c6b8d Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 5 May 2026 09:35:50 -0500 Subject: [PATCH] fix(contacts): count every contact in the per-month chart The chart is a public-facing seasonal summary, not a personal view, so private contacts should roll into the totals like any other. Drop the visible_query scope from monthly_bars and query Contact directly. --- lib/microwaveprop_web/live/contact_live/index.ex | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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)})