Is it possible to test metric without data in DB?


I mean, is it possible to inject “in memory” data, from a javascript list for example", into a metric ?


I think you can take a look at Timeseries.fromObjs

var result = RegisterMeasurement.fetch({ filter:‘start’, DateTime.parse(‘2017-05-25’, ‘yyyy-MM-dd’)).and.le(‘start’, DateTime.parse(‘2017-06-03’, ‘yyyy-MM-dd’)).and.eq(‘’, ‘3a40396f8e06b63fad62a386ffc1f26c’)})

var timeseries = Timeseries.fromObjs(ObjArry.fromArry(result.objs), {start: ‘2017-05-25’, end: ‘2017-06-03’, interval: ‘DAY’}, {treatment: ‘PREVIOUS’, startPath: ‘start’, valuePath: ‘quantity’, dataVersionPath: ‘version’, isEstimatedPath: ‘isEstimated’})


If you are testing a compound metric you can use bindings:

bindings =;
bindings.set(“WellMeasurementTorque”, Timeseries.makeNorm(NormTimeseriesDoubleSpec.make({
“start”: “2016-01-01”,
“end”: “2016-01-04”,
“interval”: “DAY”,
“data”: [40, 50, 60]

bindings.set(“WellMeasurementPumpSpeed”, Timeseries.makeNorm(NormTimeseriesDoubleSpec.make({
“start”: “2016-01-01”,
“end”: “2016-01-04”,
“interval”: “DAY”,
“data”: [10, 28, 30]

var results = PCPWell.evalMetric({
id: “ogw”,
expression: “PumpIsOperating”,
interval: “DAY”,
start: “2016-01-01”,
end: “2016-01-04”,
bindings: bindings

Where PumpIsOperating is defined as:
“id” : “PumpIsOperating”,
“name” : “PumpIsOperating”,
“expression” : “WellMeasurementTorque > 50 && WellMeasurementPumpSpeed > 28”

Note that if you do not supply values for some metrics that are present in the compound metric expression, those will be treated as fully unavailable.