Default value for overlapHandling with a boolean

#1

The documentation says the default treatment for overlapHandling is AVG. Is it still valid for boolean?

0 Likes

#2

To be honest I’m not quite sure. I set up the following small example:

var context = TestApi.createContext('test'),
  servicePoint = TestApi.createEntity(context, 'ServicePoint'),
  measurementSeries = TestApi.createEntity(context, 'PointPhysicalMeasurementSeries', {
    servicePoint: servicePoint,
    unitConstraint: { id: 'kw' }
  });

var measurements = [
  {
    parent: measurementSeries,
    quantity: { value: 5 },
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-3)
  },
  {
    parent: measurementSeries,
    quantity: { value: 5 },
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-2)
  },
  {
    parent: measurementSeries,
    quantity: { value: 10 },
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-2)
  },
  {
    parent: measurementSeries,
    quantity: { value: 10 },
    start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-1)
  }
];

TestApi.createBatchEntity(context, 'PointMeasurement', measurements);

evaluating the following behaves as you would expect:

ServicePoint.evalMetricsWithMetadata({
  ids: [servicePoint.id],
  expressions: ['MyTestMetric'],
  start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-3),
  end: DateTime.nowWithoutZone().toDateMidnight(),
  interval: 'DAY'
}, [
    SimpleMetric.make({
      "id": "MyTestMetric_ServicePoint",
      "name": "MyTestMetric",
      "srcType": "ServicePoint",
      "path": "pointMeasurements",
      "tsDecl": {
        "data": "data",
        "treatment": "LATEST",
        "start": "start",
        "value": "quantity"
      }
    })
  ]).at('result["' + servicePoint.id + '"]').MyTestMetric.data()

[5, 7.5, 10]

But then I get this when trying to cast to a boolean:

ServicePoint.evalMetricsWithMetadata({
  ids: [servicePoint.id],
  expressions: ['MyTestMetric'],
  start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-3),
  end: DateTime.nowWithoutZone().toDateMidnight(),
  interval: 'DAY'
}, [
    SimpleMetric.make({
      "id": "MyTestMetric_ServicePoint",
      "name": "MyTestMetric",
      "srcType": "ServicePoint",
      "path": "pointMeasurements",
      "tsDecl": {
        "data": "data",
        "treatment": "LATEST",
        "start": "start",
        "value": "quantity == 10"
      }
    })
  ]).at('result["' + servicePoint.id + '"]').MyTestMetric.data()

[0, 1, 1]

even with overlapHandling explicitly set to ‘AVG’ you get the same result of [0, 1, 1] here

0 Likes