fix(dashboard): Top Senders — accurate counts and no stacked bars - #429
Open
CafeLungo wants to merge 2 commits into
Open
fix(dashboard): Top Senders — accurate counts and no stacked bars#429CafeLungo wants to merge 2 commits into
CafeLungo wants to merge 2 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sfromfacet distribution(
index.search('', { facets: ['from'] })). ButconfigureEmailIndex()never set anyfacetingconfig, so Meilisearch applied its defaults:maxValuesPerFacet: 100— only 100 of the many thousands of distinct senders are returnedsortFacetValuesBy: 'alpha'— those 100 are the alphabetically-first addresses, not the most frequentgetTopSenders()then sorted that arbitrary alphabetical slice by count and took thetop 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:
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.sveltekeys each bar onsender— the y-axis category — afteroverwriting 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.comandupdate+…@facebookmail.comboth → "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.