Dashboard Refactor: Flow-based Metrics + Unified Data Model #4

Merged
aetos merged 11 commits from cached-reports into main 2026-05-18 05:37:52 +00:00
2 changed files with 21 additions and 17 deletions
Showing only changes of commit 58271584ce - Show all commits

View File

@@ -14,24 +14,31 @@ function extractTransactions(
selectedPeriodId: string | null, selectedPeriodId: string | null,
selectedGroupKey: GroupKey | null, selectedGroupKey: GroupKey | null,
): Transaction[] { ): Transaction[] {
const buckets = filterBuckets(reportData.buckets, selectedGroupKey); // 1. Get raw transactions
let rawTxns: Transaction[] = [];
if (selectedPeriodId) { if (selectedPeriodId) {
const key = periodIdToKey(selectedPeriodId); const key = periodIdToKey(selectedPeriodId);
const periods = mergeBucketPeriods(buckets, key); const periods = mergeBucketPeriods(reportData.buckets, key);
const selected = periods.find((p) => p.id === selectedPeriodId); const selected = periods.find((p) => p.id === selectedPeriodId);
rawTxns = selected?.metric.transactions || [];
if (!selected) return []; } else {
const periods = mergeBucketPeriods(reportData.buckets, "all");
return selected.metric.transactions || []; if (periods.length > 0) {
rawTxns = periods[0].metric.transactions || [];
}
} }
const periods = mergeBucketPeriods(buckets, "all"); // 2. Filter by group key
if (selectedGroupKey?.tags && selectedGroupKey.tags.length > 0) {
return rawTxns.filter(txn => {
if (!txn.tags) return false;
const txnTags = txn.tags.map(t => typeof t === "string" ? t : t.name);
return selectedGroupKey.tags!.every(selectedTag => txnTags.includes(selectedTag));
});
}
if (!periods.length) return []; return rawTxns;
const full = periods[0];
return full.metric.transactions || [];
} }
// ─── Main adapter ──────────────────────────────────────────── // ─── Main adapter ────────────────────────────────────────────

View File

@@ -26,14 +26,11 @@ export default function LatestItems({
return buildLatestItems(reportData, selectedPeriodId, selectedGroupKey, mode); return buildLatestItems(reportData, selectedPeriodId, selectedGroupKey, mode);
}, [reportData, selectedPeriodId, selectedGroupKey, mode]); }, [reportData, selectedPeriodId, selectedGroupKey, mode]);
const hasSelection = Boolean(selectedPeriodId) || Boolean(selectedGroupKey);
const visibleItems = React.useMemo(() => { const visibleItems = React.useMemo(() => {
if (!hasSelection) return allItems.slice(0, 5);
return allItems.slice(0, visibleCount); return allItems.slice(0, visibleCount);
}, [allItems, hasSelection, visibleCount]); }, [allItems, visibleCount]);
const canExpand = hasSelection && visibleCount < allItems.length; const canExpand = visibleCount < allItems.length;
return ( return (
<LatestItemsView <LatestItemsView