blob: 74ade7d48aa8714ccbeb499e249d01265798aa04 (
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
27
28
29
|
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { ARCHIVE_FILE_TYPE, METADATA_FILE_TYPE, JOB_STATUS_GROUP_SUCCESS } from './constants';
export const totalArtifactsSizeForJob = (job) =>
numberToHumanSize(
job.artifacts.nodes
.map((artifact) => Number(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,
hasMetadata: jobNode.artifacts.nodes.some(
(artifact) => artifact.fileType === METADATA_FILE_TYPE,
),
...jobNode,
};
};
|