Initial
This commit is contained in:
@@ -17,11 +17,26 @@ function visibleJobClause() {
|
||||
function outputSelect() {
|
||||
return `
|
||||
SELECT jo.*, j.status AS job_status, j.runplan_id, j.script_id, j.triggered_by,
|
||||
r.name AS runplan_name, s.name AS script_name
|
||||
r.name AS runplan_name, s.name AS script_name,
|
||||
COALESCE(hs.host_total_count, 0) AS host_total_count,
|
||||
COALESCE(hs.host_success_count, 0) AS host_success_count,
|
||||
COALESCE(hs.host_failed_count, 0) AS host_failed_count,
|
||||
COALESCE(hs.host_skipped_count, 0) AS host_skipped_count,
|
||||
COALESCE(hs.host_canceled_count, 0) AS host_canceled_count
|
||||
FROM job_outputs jo
|
||||
JOIN jobs j ON j.id = jo.job_id
|
||||
LEFT JOIN runplans r ON r.id = j.runplan_id
|
||||
LEFT JOIN scripts s ON s.id = j.script_id
|
||||
LEFT JOIN (
|
||||
SELECT job_id,
|
||||
COUNT(*) AS host_total_count,
|
||||
SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) AS host_success_count,
|
||||
SUM(CASE WHEN status = 'failed' THEN 1 ELSE 0 END) AS host_failed_count,
|
||||
SUM(CASE WHEN status = 'skipped' THEN 1 ELSE 0 END) AS host_skipped_count,
|
||||
SUM(CASE WHEN status = 'canceled' THEN 1 ELSE 0 END) AS host_canceled_count
|
||||
FROM job_hosts
|
||||
GROUP BY job_id
|
||||
) hs ON hs.job_id = j.id
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,6 +453,19 @@ export function camelJobLog(row) {
|
||||
}
|
||||
|
||||
export function camelJobOutput(row) {
|
||||
const hostSuccessCount = row.host_success_count || 0;
|
||||
const hostFailedCount = row.host_failed_count || 0;
|
||||
const hostSkippedCount = row.host_skipped_count || 0;
|
||||
const hostCanceledCount = row.host_canceled_count || 0;
|
||||
const outputStatus = hostSuccessCount > 0
|
||||
? 'completed'
|
||||
: hostFailedCount > 0
|
||||
? 'failed'
|
||||
: hostCanceledCount > 0
|
||||
? 'canceled'
|
||||
: hostSkippedCount > 0
|
||||
? 'skipped'
|
||||
: row.job_status || row.status || '';
|
||||
return {
|
||||
id: row.id,
|
||||
jobId: row.job_id,
|
||||
@@ -467,6 +480,12 @@ export function camelJobOutput(row) {
|
||||
scriptId: row.script_id || null,
|
||||
scriptName: row.script_name || null,
|
||||
jobStatus: row.job_status || row.status || '',
|
||||
outputStatus,
|
||||
hostTotalCount: row.host_total_count || 0,
|
||||
hostSuccessCount,
|
||||
hostFailedCount,
|
||||
hostSkippedCount,
|
||||
hostCanceledCount,
|
||||
triggeredBy: row.triggered_by || null,
|
||||
createdAt: row.created_at,
|
||||
updatedAt: row.updated_at,
|
||||
|
||||
Reference in New Issue
Block a user