Skip to content

Commit

Permalink
feat: support basic alert for remaining visualizations
Browse files Browse the repository at this point in the history
JIRA: F1-773
  • Loading branch information
hackerstanislav committed Oct 2, 2024
1 parent 48f4c9d commit 200de3e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ function collectAllMetric(insight: IInsight | null | undefined): {
} {
const insightType = insight ? (insightVisualizationType(insight) as InsightType) : null;

if (!insight) {
return {
primaries: [],
others: [],
};
}

switch (insightType) {
case "headline":
case "bar":
Expand All @@ -255,47 +262,24 @@ function collectAllMetric(insight: IInsight | null | undefined): {
case "area":
case "combo2":
case "scatter":
case "bubble": {
const insightMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.MEASURES)
: undefined;
const insightSecondaryMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.SECONDARY_MEASURES)
: undefined;
const insightTertiaryMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.TERTIARY_MEASURES)
: undefined;

return {
primaries: insightMeasuresBucket ? bucketMeasures(insightMeasuresBucket) : [],
others: [
...(insightSecondaryMeasuresBucket ? bucketMeasures(insightSecondaryMeasuresBucket) : []),
...(insightTertiaryMeasuresBucket ? bucketMeasures(insightTertiaryMeasuresBucket) : []),
],
};
}
case "repeater": {
const insightColumnsBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.COLUMNS)
: undefined;

return {
primaries: insightColumnsBucket ? bucketMeasures(insightColumnsBucket) : [],
others: [],
};
}
case "donut":
case "treemap":
case "heatmap":
case "bubble":
case "bullet":
case "table":
case "pushpin":
case "pie":
case "sankey":
case "dependencywheel":
case "donut":
case "treemap":
case "funnel":
case "pyramid":
case "heatmap":
case "waterfall":
case "dependencywheel":
case "sankey":
case "pushpin":
case "table": {
return collectAllMetricsDefault(insight);
}
case "repeater": {
return collectAllMetricsRepeater(insight);
}
default: {
return {
primaries: [],
Expand All @@ -305,6 +289,37 @@ function collectAllMetric(insight: IInsight | null | undefined): {
}
}

function collectAllMetricsDefault(insight: IInsight) {
const insightMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.MEASURES)
: undefined;
const insightSecondaryMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.SECONDARY_MEASURES)
: undefined;
const insightTertiaryMeasuresBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.TERTIARY_MEASURES)
: undefined;

return {
primaries: insightMeasuresBucket ? bucketMeasures(insightMeasuresBucket) : [],
others: [
...(insightSecondaryMeasuresBucket ? bucketMeasures(insightSecondaryMeasuresBucket) : []),
...(insightTertiaryMeasuresBucket ? bucketMeasures(insightTertiaryMeasuresBucket) : []),
],
};
}

function collectAllMetricsRepeater(insight: IInsight) {
const insightColumnsBucket: IBucket | undefined = insight
? insightBucket(insight, BucketNames.COLUMNS)
: undefined;

return {
primaries: insightColumnsBucket ? bucketMeasures(insightColumnsBucket) : [],
others: [],
};
}

export function getValueSuffix(alert?: IAutomationAlert): string | undefined {
if (isChangeOperator(alert)) {
return "%";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ export const isInsightSupportedForAlerts = (
case "scatter":
case "bubble":
case "repeater":
case "bullet":
case "pie":
case "donut":
case "treemap":
case "funnel":
case "pyramid":
case "heatmap":
case "waterfall":
case "dependencywheel":
case "sankey":
case "pushpin":
case "table":
return true;
default:
return false;
Expand Down

0 comments on commit 200de3e

Please sign in to comment.