-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfindDuplicateLineProtocolPoints.js
More file actions
33 lines (29 loc) · 1.02 KB
/
findDuplicateLineProtocolPoints.js
File metadata and controls
33 lines (29 loc) · 1.02 KB
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
/*
* Query data points on a single data source and check point locator values
* to determine if there are any multiple points. This was used in testing
* the sychronization of the data source logic.
*/
let count = 0;
const uniqueKeys = [];
const duplicatePoints = [];
const limit = 500000;
const logInterval = 1000;
services.dataPointService.buildQuery()
.equal('dataSourceId', 7)
.query((dp) => {
const locator = dp.getPointLocator();
//Create unique key and check to see if already exists
const key = locator.getMeasurement() + locator.getFieldKey();
if(uniqueKeys.includes(key)) {
duplicatePoints.push(dp);
}else {
uniqueKeys.push(key);
}
if((count % logInterval) == 0) {
log.info('Processed ' + count);
}
count++;
}, limit, 0);
duplicatePoints.forEach(dp => {
log.info('Point ' + dp.getId() + ' measurement: ' + dp.getPointLocator().getMeasurement() + ' fieldKey: ' + dp.getPointLocator().getFieldKey());
});