summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/pipelines/getters.js
blob: fea77b661b5ed1b10d6c8e5c28bfa9487522e427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export const hasLatestPipeline = state => !state.isLoadingPipeline && !!state.latestPipeline;

export const pipelineFailed = state =>
  state.latestPipeline && state.latestPipeline.details.status.text === 'failed';

export const failedStages = state =>
  state.stages.filter(stage => stage.status.text === 'failed').map(stage => ({
    ...stage,
    jobs: stage.jobs.filter(job => job.status.text === 'failed'),
  }));

export const failedJobsCount = state =>
  state.stages.reduce(
    (acc, stage) => acc + stage.jobs.filter(j => j.status.text === 'failed').length,
    0,
  );

export const jobsCount = state => state.stages.reduce((acc, stage) => acc + stage.jobs.length, 0);