feat(dashboard): order Workstreams by Domain chart by most recent activity

Domains are sorted top-to-bottom by the latest updated_at across their
workstreams (most recently active domain first). Within a domain,
workstreams are also ordered by updated_at desc. Replaces alphabetical sort.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 09:24:06 +01:00
parent b744a0de2c
commit 74872e0b6a

View File

@@ -188,7 +188,7 @@ function _timeCutoff(mode) {
return null;
}
const chartWs = (
const _chartWsFiltered = (
_STATUS_MODES.has(_chartMode)
? wsAll.filter(w => w.status === _chartMode)
: _chartMode === "accepted"
@@ -217,7 +217,20 @@ const chartWs = (
new Date(w.updated_at) >= since || new Date(w.created_at) >= since
);
})()
).sort((a, b) => a.domain.localeCompare(b.domain) || a.title.localeCompare(b.title));
);
// Sort domains top-to-bottom by most recent workstream update (most active domain first).
// Within a domain, most recently updated workstream comes first.
const _domainLatest = {};
for (const w of _chartWsFiltered) {
const t = new Date(w.updated_at).getTime();
if (!_domainLatest[w.domain] || t > _domainLatest[w.domain]) _domainLatest[w.domain] = t;
}
const chartWs = [..._chartWsFiltered].sort((a, b) => {
const dd = (_domainLatest[b.domain] ?? 0) - (_domainLatest[a.domain] ?? 0);
if (dd !== 0) return dd;
return new Date(b.updated_at) - new Date(a.updated_at);
});
// ── Status weight: bold for notable statuses in mixed-status modes ─────────────
// Color is NOT used for status — avoids green-on-green when completed bars fill the row.