Commit 758df331 authored by Reuben Pereira's avatar Reuben Pereira

Revert "Merge branch '340057-alias-the-needs-in-the-pipeline-graph' into 'master'"

This reverts merge request !75139
parent c7d10cb5
import { memoize } from 'lodash'; import { memoize } from 'lodash';
import { createNodeDict } from '../utils'; import { createNodeDict } from '../utils';
import { EXPLICIT_NEEDS_PROPERTY, NEEDS_PROPERTY } from '../constants';
import { createSankey } from './dag/drawing_utils'; import { createSankey } from './dag/drawing_utils';
/* /*
...@@ -16,14 +15,12 @@ const deduplicate = (item, itemIndex, arr) => { ...@@ -16,14 +15,12 @@ const deduplicate = (item, itemIndex, arr) => {
return foundIdx === itemIndex; return foundIdx === itemIndex;
}; };
export const makeLinksFromNodes = (nodes, nodeDict, { needsKey = NEEDS_PROPERTY } = {}) => { export const makeLinksFromNodes = (nodes, nodeDict) => {
const constantLinkValue = 10; // all links are the same weight const constantLinkValue = 10; // all links are the same weight
return nodes return nodes
.map(({ jobs, name: groupName }) => .map(({ jobs, name: groupName }) =>
jobs.map((job) => { jobs.map(({ needs = [] }) =>
const needs = job[needsKey] || []; needs.reduce((acc, needed) => {
return needs.reduce((acc, needed) => {
// It's possible that we have an optional job, which // It's possible that we have an optional job, which
// is being needed by another job. In that scenario, // is being needed by another job. In that scenario,
// the needed job doesn't exist, so we don't want to // the needed job doesn't exist, so we don't want to
...@@ -37,8 +34,8 @@ export const makeLinksFromNodes = (nodes, nodeDict, { needsKey = NEEDS_PROPERTY ...@@ -37,8 +34,8 @@ export const makeLinksFromNodes = (nodes, nodeDict, { needsKey = NEEDS_PROPERTY
} }
return acc; return acc;
}, []); }, []),
}), ),
) )
.flat(2); .flat(2);
}; };
...@@ -79,9 +76,9 @@ export const filterByAncestors = (links, nodeDict) => ...@@ -79,9 +76,9 @@ export const filterByAncestors = (links, nodeDict) =>
return !allAncestors.includes(source); return !allAncestors.includes(source);
}); });
export const parseData = (nodes, { needsKey = NEEDS_PROPERTY } = {}) => { export const parseData = (nodes) => {
const nodeDict = createNodeDict(nodes, { needsKey }); const nodeDict = createNodeDict(nodes);
const allLinks = makeLinksFromNodes(nodes, nodeDict, { needsKey }); const allLinks = makeLinksFromNodes(nodes, nodeDict);
const filteredLinks = allLinks.filter(deduplicate); const filteredLinks = allLinks.filter(deduplicate);
const links = filterByAncestors(filteredLinks, nodeDict); const links = filterByAncestors(filteredLinks, nodeDict);
...@@ -126,8 +123,7 @@ export const removeOrphanNodes = (sankeyfiedNodes) => { ...@@ -126,8 +123,7 @@ export const removeOrphanNodes = (sankeyfiedNodes) => {
export const listByLayers = ({ stages }) => { export const listByLayers = ({ stages }) => {
const arrayOfJobs = stages.flatMap(({ groups }) => groups); const arrayOfJobs = stages.flatMap(({ groups }) => groups);
const parsedData = parseData(arrayOfJobs); const parsedData = parseData(arrayOfJobs);
const explicitParsedData = parseData(arrayOfJobs, { needsKey: EXPLICIT_NEEDS_PROPERTY }); const dataWithLayers = createSankey()(parsedData);
const dataWithLayers = createSankey()(explicitParsedData);
const pipelineLayers = dataWithLayers.nodes.reduce((acc, { layer, name }) => { const pipelineLayers = dataWithLayers.nodes.reduce((acc, { layer, name }) => {
/* sort groups by layer */ /* sort groups by layer */
......
import { reportToSentry } from '../utils'; import { reportToSentry } from '../utils';
import { EXPLICIT_NEEDS_PROPERTY, NEEDS_PROPERTY } from '../constants';
const unwrapGroups = (stages) => { const unwrapGroups = (stages) => {
return stages.map((stage, idx) => { return stages.map((stage, idx) => {
...@@ -28,16 +27,12 @@ const unwrapNodesWithName = (jobArray, prop, field = 'name') => { ...@@ -28,16 +27,12 @@ const unwrapNodesWithName = (jobArray, prop, field = 'name') => {
} }
return jobArray.map((job) => { return jobArray.map((job) => {
if (job[prop]) {
return { ...job, [prop]: job[prop].nodes.map((item) => item[field] || '') }; return { ...job, [prop]: job[prop].nodes.map((item) => item[field] || '') };
}
return job;
}); });
}; };
const unwrapJobWithNeeds = (denodedJobArray) => { const unwrapJobWithNeeds = (denodedJobArray) => {
const explicitNeedsUnwrapped = unwrapNodesWithName(denodedJobArray, EXPLICIT_NEEDS_PROPERTY); return unwrapNodesWithName(denodedJobArray, 'needs');
return unwrapNodesWithName(explicitNeedsUnwrapped, NEEDS_PROPERTY);
}; };
const unwrapStagesWithNeedsAndLookup = (denodedStages) => { const unwrapStagesWithNeedsAndLookup = (denodedStages) => {
......
...@@ -7,8 +7,6 @@ export const ANY_TRIGGER_AUTHOR = 'Any'; ...@@ -7,8 +7,6 @@ export const ANY_TRIGGER_AUTHOR = 'Any';
export const SUPPORTED_FILTER_PARAMETERS = ['username', 'ref', 'status', 'source']; export const SUPPORTED_FILTER_PARAMETERS = ['username', 'ref', 'status', 'source'];
export const FILTER_TAG_IDENTIFIER = 'tag'; export const FILTER_TAG_IDENTIFIER = 'tag';
export const SCHEDULE_ORIGIN = 'schedule'; export const SCHEDULE_ORIGIN = 'schedule';
export const NEEDS_PROPERTY = 'needs';
export const EXPLICIT_NEEDS_PROPERTY = 'previousStageJobsOrNeeds';
export const TestStatus = { export const TestStatus = {
FAILED: 'failed', FAILED: 'failed',
......
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { pickBy } from 'lodash'; import { pickBy } from 'lodash';
import { SUPPORTED_FILTER_PARAMETERS, NEEDS_PROPERTY } from './constants'; import { SUPPORTED_FILTER_PARAMETERS } from './constants';
/* /*
The following functions are the main engine in transforming the data as The following functions are the main engine in transforming the data as
...@@ -35,11 +35,11 @@ import { SUPPORTED_FILTER_PARAMETERS, NEEDS_PROPERTY } from './constants'; ...@@ -35,11 +35,11 @@ import { SUPPORTED_FILTER_PARAMETERS, NEEDS_PROPERTY } from './constants';
10 -> value (constant) 10 -> value (constant)
*/ */
export const createNodeDict = (nodes, { needsKey = NEEDS_PROPERTY } = {}) => { export const createNodeDict = (nodes) => {
return nodes.reduce((acc, node) => { return nodes.reduce((acc, node) => {
const newNode = { const newNode = {
...node, ...node,
needs: node.jobs.map((job) => job[needsKey] || []).flat(), needs: node.jobs.map((job) => job.needs || []).flat(),
}; };
if (node.size > 1) { if (node.size > 1) {
......
...@@ -91,14 +91,6 @@ query getPipelineDetails($projectPath: ID!, $iid: ID!) { ...@@ -91,14 +91,6 @@ query getPipelineDetails($projectPath: ID!, $iid: ID!) {
name name
} }
} }
previousStageJobsOrNeeds {
__typename
nodes {
__typename
id
name
}
}
status: detailedStatus { status: detailedStatus {
__typename __typename
id id
......
...@@ -13,7 +13,6 @@ Array [ ...@@ -13,7 +13,6 @@ Array [
"id": "6", "id": "6",
"name": "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", "name": "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -54,7 +53,6 @@ Array [ ...@@ -54,7 +53,6 @@ Array [
"id": "11", "id": "11",
"name": "build_b", "name": "build_b",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -95,7 +93,6 @@ Array [ ...@@ -95,7 +93,6 @@ Array [
"id": "16", "id": "16",
"name": "build_c", "name": "build_c",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -136,7 +133,6 @@ Array [ ...@@ -136,7 +133,6 @@ Array [
"id": "21", "id": "21",
"name": "build_d 1/3", "name": "build_d 1/3",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -161,7 +157,6 @@ Array [ ...@@ -161,7 +157,6 @@ Array [
"id": "24", "id": "24",
"name": "build_d 2/3", "name": "build_d 2/3",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -186,7 +181,6 @@ Array [ ...@@ -186,7 +181,6 @@ Array [
"id": "27", "id": "27",
"name": "build_d 3/3", "name": "build_d 3/3",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -227,7 +221,6 @@ Array [ ...@@ -227,7 +221,6 @@ Array [
"id": "59", "id": "59",
"name": "test_c", "name": "test_c",
"needs": Array [], "needs": Array [],
"previousStageJobsOrNeeds": Array [],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -274,11 +267,6 @@ Array [ ...@@ -274,11 +267,6 @@ Array [
"build_b", "build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
], ],
"previousStageJobsOrNeeds": Array [
"build_c",
"build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -325,13 +313,6 @@ Array [ ...@@ -325,13 +313,6 @@ Array [
"build_b", "build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
], ],
"previousStageJobsOrNeeds": Array [
"build_d 3/3",
"build_d 2/3",
"build_d 1/3",
"build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -362,13 +343,6 @@ Array [ ...@@ -362,13 +343,6 @@ Array [
"build_b", "build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl", "build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
], ],
"previousStageJobsOrNeeds": Array [
"build_d 3/3",
"build_d 2/3",
"build_d 1/3",
"build_b",
"build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl",
],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
...@@ -411,9 +385,6 @@ Array [ ...@@ -411,9 +385,6 @@ Array [
"needs": Array [ "needs": Array [
"build_b", "build_b",
], ],
"previousStageJobsOrNeeds": Array [
"build_b",
],
"scheduledAt": null, "scheduledAt": null,
"status": Object { "status": Object {
"__typename": "DetailedStatus", "__typename": "DetailedStatus",
......
...@@ -73,10 +73,6 @@ export const mockPipelineResponse = { ...@@ -73,10 +73,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
], ],
}, },
...@@ -122,10 +118,6 @@ export const mockPipelineResponse = { ...@@ -122,10 +118,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
], ],
}, },
...@@ -171,10 +163,6 @@ export const mockPipelineResponse = { ...@@ -171,10 +163,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
], ],
}, },
...@@ -220,10 +208,6 @@ export const mockPipelineResponse = { ...@@ -220,10 +208,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
{ {
__typename: 'CiJob', __typename: 'CiJob',
...@@ -251,10 +235,6 @@ export const mockPipelineResponse = { ...@@ -251,10 +235,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
{ {
__typename: 'CiJob', __typename: 'CiJob',
...@@ -282,10 +262,6 @@ export const mockPipelineResponse = { ...@@ -282,10 +262,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
], ],
}, },
...@@ -363,27 +339,6 @@ export const mockPipelineResponse = { ...@@ -363,27 +339,6 @@ export const mockPipelineResponse = {
}, },
], ],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [
{
__typename: 'CiBuildNeed',
id: '37',
name: 'build_c',
},
{
__typename: 'CiBuildNeed',
id: '38',
name: 'build_b',
},
{
__typename: 'CiBuildNeed',
id: '39',
name:
'build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl',
},
],
},
}, },
], ],
}, },
...@@ -456,37 +411,6 @@ export const mockPipelineResponse = { ...@@ -456,37 +411,6 @@ export const mockPipelineResponse = {
}, },
], ],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [
{
__typename: 'CiBuildNeed',
id: '45',
name: 'build_d 3/3',
},
{
__typename: 'CiBuildNeed',
id: '46',
name: 'build_d 2/3',
},
{
__typename: 'CiBuildNeed',
id: '47',
name: 'build_d 1/3',
},
{
__typename: 'CiBuildNeed',
id: '48',
name: 'build_b',
},
{
__typename: 'CiBuildNeed',
id: '49',
name:
'build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl',
},
],
},
}, },
{ {
__typename: 'CiJob', __typename: 'CiJob',
...@@ -541,37 +465,6 @@ export const mockPipelineResponse = { ...@@ -541,37 +465,6 @@ export const mockPipelineResponse = {
}, },
], ],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [
{
__typename: 'CiBuildNeed',
id: '52',
name: 'build_d 3/3',
},
{
__typename: 'CiBuildNeed',
id: '53',
name: 'build_d 2/3',
},
{
__typename: 'CiBuildNeed',
id: '54',
name: 'build_d 1/3',
},
{
__typename: 'CiBuildNeed',
id: '55',
name: 'build_b',
},
{
__typename: 'CiBuildNeed',
id: '56',
name:
'build_a_nlfjkdnlvskfnksvjknlfdjvlvnjdkjdf_nvjkenjkrlngjeknjkl',
},
],
},
}, },
], ],
}, },
...@@ -610,10 +503,6 @@ export const mockPipelineResponse = { ...@@ -610,10 +503,6 @@ export const mockPipelineResponse = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
}, },
], ],
}, },
...@@ -658,16 +547,6 @@ export const mockPipelineResponse = { ...@@ -658,16 +547,6 @@ export const mockPipelineResponse = {
}, },
], ],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [
{
__typename: 'CiBuildNeed',
id: '65',
name: 'build_b',
},
],
},
}, },
], ],
}, },
...@@ -841,10 +720,6 @@ export const wrappedPipelineReturn = { ...@@ -841,10 +720,6 @@ export const wrappedPipelineReturn = {
__typename: 'CiBuildNeedConnection', __typename: 'CiBuildNeedConnection',
nodes: [], nodes: [],
}, },
previousStageJobsOrNeeds: {
__typename: 'CiJobConnection',
nodes: [],
},
status: { status: {
__typename: 'DetailedStatus', __typename: 'DetailedStatus',
id: '84', id: '84',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment