mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* SQLite migrations * cleanup * migrate end times * switch to update with a query * real migration * anno migrations * remove old docs * set isRegion from time changes * use <> for is not * add comment and fix index decleration * single validation place * add test * fix test * add upgrading docs * use AnnotationEvent * fix import * remove regionId from typescript
28 lines
718 B
TypeScript
28 lines
718 B
TypeScript
import _ from 'lodash';
|
|
|
|
export function dedupAnnotations(annotations: any) {
|
|
let dedup = [];
|
|
|
|
// Split events by annotationId property existence
|
|
const events = _.partition(annotations, 'id');
|
|
|
|
const eventsById = _.groupBy(events[0], 'id');
|
|
dedup = _.map(eventsById, eventGroup => {
|
|
if (eventGroup.length > 1 && !_.every(eventGroup, isPanelAlert)) {
|
|
// Get first non-panel alert
|
|
return _.find(eventGroup, event => {
|
|
return event.eventType !== 'panel-alert';
|
|
});
|
|
} else {
|
|
return _.head(eventGroup);
|
|
}
|
|
});
|
|
|
|
dedup = _.concat(dedup, events[1]);
|
|
return dedup;
|
|
}
|
|
|
|
function isPanelAlert(event: { eventType: string }) {
|
|
return event.eventType === 'panel-alert';
|
|
}
|