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.
This commit is contained in:
parent
56e9755a10
commit
1c6e9005d1
1 changed files with 7 additions and 4 deletions
|
|
@ -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)})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue