diff --git a/package.json b/package.json index ba87e1a..8ae5f28 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@bit/zencrepes.zindexer.github-repos": "^0.0.16", "@bit/zencrepes.zindexer.github-stargazers": "^0.0.10", "@bit/zencrepes.zindexer.github-watchers": "^0.0.10", - "@bit/zencrepes.zindexer.testing-perfs": "^0.0.28", + "@bit/zencrepes.zindexer.testing-perfs": "^0.0.30", "@bit/zencrepes.zindexer.testing-runs": "^0.0.3", "@bit/zencrepes.zindexer.testing-states": "^0.0.5", "@elastic/elasticsearch": "^7.9.0", diff --git a/src/perfs/perfsStorePayload.processor.ts b/src/perfs/perfsStorePayload.processor.ts index 39269b4..a74577d 100644 --- a/src/perfs/perfsStorePayload.processor.ts +++ b/src/perfs/perfsStorePayload.processor.ts @@ -2,7 +2,7 @@ import { Process, Processor } from '@nestjs/bull'; import { Logger } from '@nestjs/common'; import { Job } from 'bull'; -import { esMapping, esSettings, PerfNode, getId } from '@bit/zencrepes.zindexer.testing-perfs'; +import { esMapping, esSettings, getId } from '@bit/zencrepes.zindexer.testing-perfs'; import { checkEsIndex, pushEsNodes } from '@bit/zencrepes.zindexer.es-utils'; import { ConfigService } from '../config.service'; @@ -29,9 +29,21 @@ export class PerfsStorePayloadProcessor { // Check if the index exists, create it if it does not await checkEsIndex(esClient, userConfig.elasticsearch.dataIndices.testingPerfs, esMapping, esSettings, console.log); + // From the job data, get an array containing all available transaction name + const transactionNames = [] + for (const run of job.data.runs) { + for (const [k, v] of Object.entries(run.statistics)) { + const transaction: any = v + if (!transactionNames.includes(transaction.transaction)) { + transactionNames.push(transaction.transaction) + } + } + } + // Transforming the object, objective is just to match to GitHub's to be consistent with the rest of the app - const state: PerfNode = { + const state = { ...job.data, + id: getId(job.data), resources: { edges: job.data.resources.map((r) => { return { @@ -43,11 +55,24 @@ export class PerfsStorePayloadProcessor { }), totalCount: job.data.resources.length }, + transactions: { + edges: transactionNames.map((t) => { + return { + node: { + name: t, + } + } + }), + totalCount: transactionNames.length + }, runs: { edges: job.data.runs.map((r) => { return { node: { ...r, + statistics: Object.entries(r.statistics).map((e: any) => { + return e[1] + }), id: getId(r) } } diff --git a/yarn.lock b/yarn.lock index 84692f8..48fa6fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -412,10 +412,10 @@ dependencies: graphql-tag "^2.10.1" -"@bit/zencrepes.zindexer.testing-perfs@^0.0.28": - version "0.0.28" - resolved "https://node.bit.dev/zencrepes.zindexer.testing-perfs/-/zencrepes.zindexer.testing-perfs-0.0.28.tgz#8290f016311bea0a4acb38a1139da116ac909295" - integrity sha1-gpDwFjEb6gpKyzihE52hFqyQkpU= +"@bit/zencrepes.zindexer.testing-perfs@^0.0.30": + version "0.0.30" + resolved "https://node.bit.dev/zencrepes.zindexer.testing-perfs/-/zencrepes.zindexer.testing-perfs-0.0.30.tgz#efa9ceb225d8a4e21c2b22fad3ff3ebca5fca996" + integrity sha1-76nOsiXYpOIcKyL60/8+vKX8qZY= dependencies: "@types/uuid" "^8.3.0" uuid "^8.3.1"