File tree Expand file tree Collapse file tree 2 files changed +28
-25
lines changed
routes/projects/dryruns/[dry_run]/[resource] Expand file tree Collapse file tree 2 files changed +28
-25
lines changed Original file line number Diff line number Diff line change 11import { gql } from 'graphql-request' ;
22
33const getCarbontrackerDataQuery = gql `
4- query fetchCarbontrackerData($input: CarbonTrackerInput!) {
5- fetchCarbontrackerData(input: $input) {
6- duration
7- cpuModel
8- cpuPowerData
9- averagePowerUsage
10- energyUsage
11- location
12- carbonIntensity
13- energy
14- co2eq
15- }
16- }
4+ query fetchCarbontrackerData($input: CarbonTrackerInput!) {
5+ fetchCarbontrackerData(input: $input) {
6+ duration
7+ cpuModel
8+ cpuPowerData
9+ averagePowerUsage
10+ energyUsage
11+ location
12+ carbonIntensity
13+ energy
14+ co2eq
15+ }
16+ }
1717` ;
1818
1919export default getCarbontrackerDataQuery ;
Original file line number Diff line number Diff line change 168168 }
169169 };
170170
171- async function getCarbontrackerDataResponse(input : any ): Promise <{
172- fetchCarbontrackerData? : {
173- co2eq: number ;
174- energy: number ;
175- };
176- } | undefined > {
171+ async function getCarbontrackerDataResponse(input : any ): Promise <
172+ | {
173+ fetchCarbontrackerData? : {
174+ co2eq: number ;
175+ energy: number ;
176+ };
177+ }
178+ | undefined
179+ > {
177180 const inputData = {
178181 input: {
179182 data: {
180183 dryRun: {
181184 node: {
182185 metrics: {
183- cpuUsageSecondsTotal: input ,
186+ cpuUsageSecondsTotal: input
184187 }
185188 }
186189 }
205208 }
206209 }
207210
208-
209211 const getData = async (): Promise <{
210212 workflow: any ;
211213 dryrun: any ;
266268 }> = [];
267269 for (const step of metricsResponse ) {
268270 if (step .type === ' Pod' ) {
269- const carbonResponse = await getCarbontrackerDataResponse (step .metrics .cpuUsageSecondsTotal );
271+ const carbonResponse = await getCarbontrackerDataResponse (
272+ step .metrics .cpuUsageSecondsTotal
273+ );
270274 carbontrackerData .push ({
271275 nodeId: step .id ,
272276 stepName: step .displayName ,
273277 carbonData: carbonResponse
274278 });
275-
276279 }
277280 }
278281
279282 // Merge carbontracker data with stepsList
280- $stepsList = $stepsList .map (step => {
281- const carbonData = carbontrackerData .find (carbon => carbon .nodeId === step .id );
283+ $stepsList = $stepsList .map (( step ) => {
284+ const carbonData = carbontrackerData .find (( carbon ) => carbon .nodeId === step .id );
282285 return {
283286 ... step ,
284287 carbontracker: carbonData ? carbonData .carbonData : undefined
You can’t perform that action at this time.
0 commit comments