Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 30 31 32 33 34 35 36 37 38 39 40 | import { Task } from "../../../types";
import { updateCardById } from "../../execution/updateCardById";
import { getCurrentAsset } from "../getCurrentAsset.ts";
import { Key } from "../key.ts";
function nrGoldenMetricNameChange(task: Task) {
const source = task.source;
const taskType = (task as any)[source.toLowerCase()]?.type;
const taskKey = `${[source.toLowerCase()]}.${taskType.toLowerCase()}`;
const metrics = getCurrentAsset(
task,
Key.APPLICATION_ENTITY_NAME,
"application_name",
undefined,
"golden_metrics",
);
const handleChange = (val: any) => {
updateCardById(`${taskKey}.${Key.GOLDEN_METRIC_NAME}`, val, task.id);
const metric = metrics?.find((m) => m.golden_metric_name === val);
Iif (!metric) return;
updateCardById(
`${taskKey}.${Key.GOLDEN_METRIC_NRQL_EXPRESSION}`,
metric?.[Key.GOLDEN_METRIC_NRQL_EXPRESSION],
task.id,
);
updateCardById(
`${taskKey}.${Key.GOLDEN_METRIC_UNIT}`,
metric?.[Key.GOLDEN_METRIC_UNIT],
task.id,
);
};
return handleChange;
}
export default nrGoldenMetricNameChange;
|