Skip to content

Commit

Permalink
Fix [Jobs Monitoring] Wrong number of the total jobs and workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan7empest committed Dec 9, 2024
1 parent 995bee4 commit 5627772
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
24 changes: 9 additions & 15 deletions src/components/ProjectsPage/projects.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,21 @@ export const generateAlerts = (data, dispatch) => {
export const generateMonitoringCounters = (data, dispatch) => {
const monitoringCounters = {
jobs: {
all: 0,
completed: 0,
failed: 0,
running: 0
running: 0,
total: 0
},
workflows: {
all: 0,
completed: 0,
failed: 0,
running: 0
running: 0,
total: 0
},
scheduled: {
all: 0,
jobs: 0,
workflows: 0
workflows: 0,
total: 0
},
alerts: {
endpoint: 0,
Expand All @@ -292,29 +292,23 @@ export const generateMonitoringCounters = (data, dispatch) => {
}

data.forEach(project => {
monitoringCounters.jobs.all += project.runs_completed_recent_count || 0
monitoringCounters.jobs.all += project.runs_failed_recent_count || 0
monitoringCounters.jobs.all += project.runs_running_count || 0
monitoringCounters.jobs.all +=
monitoringCounters.jobs.total +=
project.runs_completed_recent_count ||
0 + project.runs_failed_recent_count ||
0 + project.runs_running_count ||
0
monitoringCounters.jobs.completed += project.runs_completed_recent_count || 0
monitoringCounters.jobs.failed += project.runs_failed_recent_count || 0
monitoringCounters.jobs.running += project.runs_running_count || 0
monitoringCounters.workflows.all += project.pipelines_completed_recent_count || 0
monitoringCounters.workflows.all += project.pipelines_failed_recent_count || 0
monitoringCounters.workflows.all += project.pipelines_running_count || 0
monitoringCounters.workflows.all +=
monitoringCounters.workflows.total +=
project.pipelines_completed_recent_count ||
0 + project.pipelines_failed_recent_count ||
0 + project.pipelines_running_count ||
0
monitoringCounters.workflows.completed += project.pipelines_completed_recent_count || 0
monitoringCounters.workflows.failed += project.pipelines_failed_recent_count || 0
monitoringCounters.workflows.running += project.pipelines_running_count || 0
monitoringCounters.scheduled.all +=
monitoringCounters.scheduled.total +=
project.distinct_scheduled_jobs_pending_count ||
0 + project.distinct_scheduled_pipelines_pending_count ||
0
Expand Down
4 changes: 2 additions & 2 deletions src/elements/ProjectsMonitoringCounters/JobsCounters.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ const JobsCounters = () => {
) : (
<span
className="stats__link"
onClick={jobStats.all.link}
onClick={jobStats.total.link}
data-testid="jobs_total_counter"
>
{jobStats.all.counter}
{jobStats.total.counter}
</span>
)}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ const ScheduledJobsCounters = () => {
) : (
<span
className="stats__link"
onClick={scheduledStats.all.link}
onClick={scheduledStats.total.link}
data-testid="scheduled_total_counter"
>
{scheduledStats.all.counter}
{scheduledStats.total.counter}
</span>
)}
</span>
Expand Down
4 changes: 2 additions & 2 deletions src/elements/ProjectsMonitoringCounters/WorkflowsCounters.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ const WorkflowsCounters = () => {
) : (
<span
className="stats__link"
onClick={workflowsStats.all.link}
onClick={workflowsStats.total.link}
data-testid="workflows_total_counter"
>
{workflowsStats.all.counter}
{workflowsStats.total.counter}
</span>
)}
</span>
Expand Down
12 changes: 6 additions & 6 deletions src/utils/generateMonitoringData.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const generateMonitoringStats = (data, navigate, tab) => {

return tab === JOBS_MONITORING_JOBS_TAB
? {
all: {
counter: data.all || 0,
total: {
counter: data.total || 0,
link: () => navigateToJobsMonitoringPage({ [STATUS_FILTER]: [FILTER_ALL_ITEMS] })
},
counters: [
Expand Down Expand Up @@ -70,8 +70,8 @@ export const generateMonitoringStats = (data, navigate, tab) => {
}
: tab === JOBS_MONITORING_WORKFLOWS_TAB
? {
all: {
counter: data.all || 0,
total: {
counter: data.total || 0,
link: () => navigateToJobsMonitoringPage({ [STATUS_FILTER]: [FILTER_ALL_ITEMS] })
},
counters: [
Expand Down Expand Up @@ -101,8 +101,8 @@ export const generateMonitoringStats = (data, navigate, tab) => {
]
}
: {
all: {
counter: data.all || 0,
total: {
counter: data.total || 0,
link: () => navigateToJobsMonitoringPage({ [TYPE_FILTER]: FILTER_ALL_ITEMS }, {})
},
jobs: {
Expand Down

0 comments on commit 5627772

Please sign in to comment.