Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe('getTaskTypeGroup', () => {
expect(getTaskTypeGroup('actions:def')).toEqual('actions');
});

test('should correctly group ad hoc runs under alerting', () => {
expect(getTaskTypeGroup('ad_hoc_run-backfill')).toEqual('alerting');
});

test('should return undefined if no match', () => {
expect(getTaskTypeGroup('alerting-abc')).toBeUndefined();
expect(getTaskTypeGroup('fooalertingbar')).toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@
* 2.0.
*/

const taskTypeGrouping = new Set<string>(['alerting:', 'actions:']);
const ALERT_GROUP = 'alerting';
const ACTIONS_GROUP = 'actions';
const taskTypeGrouping = new Set<string>([`${ALERT_GROUP}:`, `${ACTIONS_GROUP}:`]);

export function getTaskTypeGroup(taskType: string): string | undefined {
// we want to group ad hoc runs under alerting
if (taskType === 'ad_hoc_run-backfill') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using BACKFILL_TASK_TYPE const from the alerting plugin could be better.

return ALERT_GROUP;
}

for (const group of taskTypeGrouping) {
if (taskType.startsWith(group)) {
return group.replace(':', '');
Expand Down