Skip to content

fix(dashboard): Top Senders — accurate counts and no stacked bars - #429

Open
CafeLungo wants to merge 2 commits into
LogicLabs-OU:mainfrom
CafeLungo:fix/top-senders-facet-sort
Open

fix(dashboard): Top Senders — accurate counts and no stacked bars#429
CafeLungo wants to merge 2 commits into
LogicLabs-OU:mainfrom
CafeLungo:fix/top-senders-facet-sort

Conversation

@CafeLungo

@CafeLungo CafeLungo commented Jul 30, 2026

Copy link
Copy Markdown

Two related fixes for the dashboard's Top 10 Senders widget.


1. Counts were wildly inaccurate (backend)

Problem

On a ~200k-email archive the top bar maxed out around 25 — effectively a random/low
set of senders rather than the real leaders.

Root cause

SearchService.getTopSenders() reads Meilisearch's from facet distribution
(index.search('', { facets: ['from'] })). But configureEmailIndex() never set any
faceting config, so Meilisearch applied its defaults:

  • maxValuesPerFacet: 100 — only 100 of the many thousands of distinct senders are returned
  • sortFacetValuesBy: 'alpha' — those 100 are the alphabetically-first addresses, not the most frequent

getTopSenders() then sorted that arbitrary alphabetical slice by count and took the
top 10 — surfacing the top of an alphabetical subset, never the true high-volume
senders. The same defect affected getFacetValues() (facet typeahead suggestions).

Fix

Configure faceting on the emails index to sort facet values by count and raise the cap:

faceting: {
    maxValuesPerFacet: 1000,
    sortFacetValuesBy: { '*': 'count' },
},

Meilisearch now returns the highest-frequency facet values, so the widget sees the
real leaders. Settings-only change, applied at startup via configureEmailIndex()
no reindex required.

Verification

Ran against a live ~200k-email index; Meilisearch's facet distribution now matches the
Postgres ground truth almost exactly (Amazon 8,338 vs 8,340, Facebook 7,178 vs 7,179, …).


2. Two senders rendered as one stacked bar (frontend)

Problem

Two senders sometimes rendered as a single stacked bar (e.g. a "Facebook" row showing
1,925 + 4,832 in one bar) instead of two separate bars.

Root cause

TopSendersChart.svelte keys each bar on sender — the y-axis category — after
overwriting it with the resolved display name (senderName || address). Facet values
(addresses) are unique, but two distinct addresses can resolve to the same display
name (notification+…@facebookmail.com and update+…@facebookmail.com both → "Facebook").
Sharing a y value makes layerchart band them into one stacked bar.

Fix

Disambiguate the category: keep the bare name only when it's unique among the top
senders; when a name is shared, append the (unique) address so each sender keeps its
own bar. Bare unique names (Amazon.com, LinkedIn, …) are unchanged.

CafeLungo and others added 2 commits July 30, 2026 08:20
getTopSenders read Meilisearch's `from` facetDistribution, but the index
had no faceting config so defaults applied: maxValuesPerFacet=100 and
sortFacetValuesBy=alpha. Meilisearch returned only the alphabetically-first
100 of thousands of distinct senders, and getTopSenders sorted that
arbitrary slice by count — surfacing the top of an alphabetical subset
rather than the real top senders (max count ~25 across a 200k-email index).

Configure faceting to sort facet values by count (and raise
maxValuesPerFacet) so facetDistribution returns the highest-frequency
values. Also fixes getFacetValues typeahead suggestions. Settings-only
change, applied at startup via configureEmailIndex — no reindex required.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
TopSendersChart keys each bar on `sender`, the y-axis category, after
overwriting it with the resolved display name (senderName || address).
When two distinct addresses resolve to the SAME name (e.g. two
facebookmail.com addresses both named "Facebook"), they share a y value
and layerchart bands them into a single stacked bar instead of two rows.

Disambiguate: keep the bare name only when it is unique among the top
senders; when a name is shared, append the (unique) address so each
sender keeps its own bar. Bare unique names are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@CafeLungo CafeLungo changed the title fix(dashboard): make Top Senders use highest-count facet values fix(dashboard): Top Senders — accurate counts and no stacked bars Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant