feat(generator): enhance buildArtifact with determineArtifactStatus integration
- Change function signature to accept destructured object parameter - Integrate determineArtifactStatus for automatic status calculation - Use REPORT_NAME and COLUMNS constants (to be defined in Task 6) - Add proper filtering for partial_reasons (exclude api_/validation_ prefixes) - Add deduplication for reasons array - Update call site in buildBrowserEntrypointResult to use new signature 🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
@@ -333,11 +333,11 @@ function determineArtifactStatus({{ blockedReason = '', fatalError = '', reasons
|
||||
return 'ok';
|
||||
}}
|
||||
|
||||
function buildArtifact(args, rows) {{
|
||||
function buildArtifact({{ status, blockedReason = '', fatalError = '', reasons = [], rows = [], args }}) {{
|
||||
return {{
|
||||
type: 'report-artifact',
|
||||
report_name: '{scene_id}',
|
||||
status: rows.length > 0 ? 'ok' : 'empty',
|
||||
report_name: REPORT_NAME,
|
||||
status: status || determineArtifactStatus({{ blockedReason, fatalError, reasons, rows }}),
|
||||
period: {{
|
||||
mode: args.period_mode,
|
||||
mode_code: args.period_mode_code,
|
||||
@@ -346,11 +346,11 @@ function buildArtifact(args, rows) {{
|
||||
}},
|
||||
org: {{ label: args.org_label, code: args.org_code }},
|
||||
column_defs: COLUMN_DEFS,
|
||||
columns: {columns_json},
|
||||
columns: COLUMNS,
|
||||
rows,
|
||||
counts: {{ detail_rows: rows.length }},
|
||||
partial_reasons: [],
|
||||
reasons: []
|
||||
partial_reasons: reasons.filter(r => r && !r.startsWith('api_') && !r.startsWith('validation_')),
|
||||
reasons: Array.from(new Set(reasons.filter(Boolean)))
|
||||
}};
|
||||
}}
|
||||
|
||||
@@ -423,7 +423,7 @@ async function buildBrowserEntrypointResult(args, deps = defaultDeps) {{
|
||||
try {{
|
||||
const rawData = await (deps.queryData ? deps.queryData(args) : Promise.resolve([]));
|
||||
const rows = normalizeRows(rawData);
|
||||
return buildArtifact(args, rows);
|
||||
return buildArtifact({{ args, rows }});
|
||||
}} catch (error) {{
|
||||
return {{
|
||||
type: 'report-artifact',
|
||||
|
||||
Reference in New Issue
Block a user