Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « artifacts « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ebcf0af8d2a1789af46ae94f1a32f90105310135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { ARCHIVE_FILE_TYPE, JOB_STATUS_GROUP_SUCCESS } from './constants';

export const totalArtifactsSizeForJob = (job) =>
  numberToHumanSize(
    job.artifacts.nodes
      .map((artifact) => artifact.size)
      .reduce((total, artifact) => total + artifact, 0),
  );

export const mapArchivesToJobNodes = (jobNode) => {
  return {
    archive: {
      ...jobNode.artifacts.nodes.find((artifact) => artifact.fileType === ARCHIVE_FILE_TYPE),
    },
    ...jobNode,
  };
};

export const mapBooleansToJobNodes = (jobNode) => {
  return {
    succeeded: jobNode.detailedStatus.group === JOB_STATUS_GROUP_SUCCESS,
    hasArtifacts: jobNode.artifacts.nodes.length > 0,
    ...jobNode,
  };
};