feat(frontend): listExportableParams enumerates export options
This commit is contained in:
@@ -21,3 +21,35 @@ export function extractValue(status, param) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the grouped, ordered list of exportable parameters.
|
||||
// Session metrics (total, success_rate, then each dynamic count category found
|
||||
// in the data) come first; then every field defined in the daily template,
|
||||
// including inactive ones (historical data may exist).
|
||||
export function listExportableParams(dailyTemplate, statuses) {
|
||||
const params = [
|
||||
{ id: '__total__', label: 'Total attempts', group: 'metrics', kind: 'total' },
|
||||
{ id: '__success_rate__', label: 'Success rate', group: 'metrics', kind: 'success_rate' },
|
||||
];
|
||||
|
||||
const cats = new Set();
|
||||
for (const s of statuses ?? []) {
|
||||
const counts = s?.analysis_summary?.counts;
|
||||
if (counts && typeof counts === 'object') {
|
||||
for (const k of Object.keys(counts)) cats.add(k);
|
||||
}
|
||||
}
|
||||
for (const cat of [...cats].sort()) {
|
||||
params.push({ id: `__cat__${cat}`, label: cat, group: 'metrics', kind: 'category', category: cat });
|
||||
}
|
||||
|
||||
for (const f of dailyTemplate ?? []) {
|
||||
if (f.builtin) {
|
||||
params.push({ id: `b:${f.fieldId}`, label: f.label, group: 'daily', kind: 'builtin', statusKey: f.key });
|
||||
} else {
|
||||
params.push({ id: `c:${f.fieldId}`, label: f.label, group: 'daily', kind: 'custom', fieldId: f.fieldId });
|
||||
}
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user