txn filtering based on tags
This commit is contained in:
@@ -14,24 +14,31 @@ function extractTransactions(
|
||||
selectedPeriodId: string | null,
|
||||
selectedGroupKey: GroupKey | null,
|
||||
): Transaction[] {
|
||||
const buckets = filterBuckets(reportData.buckets, selectedGroupKey);
|
||||
// 1. Get raw transactions
|
||||
let rawTxns: Transaction[] = [];
|
||||
|
||||
if (selectedPeriodId) {
|
||||
const key = periodIdToKey(selectedPeriodId);
|
||||
const periods = mergeBucketPeriods(buckets, key);
|
||||
const periods = mergeBucketPeriods(reportData.buckets, key);
|
||||
const selected = periods.find((p) => p.id === selectedPeriodId);
|
||||
|
||||
if (!selected) return [];
|
||||
|
||||
return selected.metric.transactions || [];
|
||||
rawTxns = selected?.metric.transactions || [];
|
||||
} else {
|
||||
const periods = mergeBucketPeriods(reportData.buckets, "all");
|
||||
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 [];
|
||||
|
||||
const full = periods[0];
|
||||
|
||||
return full.metric.transactions || [];
|
||||
return rawTxns;
|
||||
}
|
||||
|
||||
// ─── Main adapter ────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user