Sort 'Latest Portfolios' by recency + relative timestamp#32
Merged
Conversation
The card on / listed slugs in non-deterministic order (DynamicSupervisor child order) which was effectively random — users couldn't tell which portfolios had recent activity. Now sorted by most-recently-updated and labelled with a compact relative timestamp. - PortfolioWorker: new `updated_at` field on the defstruct, stamped on every `:update_holdings` cast and on init (nil) so an idle worker doesn't show up as freshly active. - Store: persists `updated_at` alongside holdings / base_currency / stats, and feeds it back through a `__updated_at` payload override on restore so a server restart doesn't make every portfolio look new. - DashboardAggregator: new `recent_portfolios` derived field — top 5 sorted by `updated_at` desc, excluding workers that haven't received a payload yet. - DashboardLive: template renders the new list with a small `relative_time/1` helper (just now / Nm / Nh / Nd / Nw ago, gettext'd). 33 tests / 0 failures.
The original gate (Enum.reject is_nil) wiped the list every time the
server restarted: workers restored from pre-`updated_at` DETS rows had
no timestamp yet, so the empty-state took over until each portfolio
got a fresh Quantic broadcast.
Sort by updated_at desc but keep nil-timestamp portfolios at the
bottom of the list — they still appear, just without a label
('—' in the template) until their next update.
The card label was misleading once the sort criterion changed: it's ordered by `updated_at` desc, so "Recently Updated" is the honest name. Also bump Popular Stocks / Recently Updated / Trending This Week to a consistent max of 10 entries each (popular was already 10; recent went 5 → 10; trending went 5 → 10).
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.
Summary
The card on `/` listed portfolio slugs in non-deterministic order (whatever order `DynamicSupervisor.which_children` returned). Effectively random — users couldn't tell which portfolios had recent activity. Now sorted by most-recently-updated, capped at top 5, with a compact relative timestamp.
How
33 tests / 0 failures.
Test plan