query to get time series data for rooms in a facility

The structure of my data is as follows

 

Facilities

Rooms

Measurement Type Attribute (temp, humidity, air pressure etc)

Time Series stream

 

Given a facility and a measurement type, and a date range I want to get a list of rooms with the time series measurement values - the ultimate goal being getting data for some bar charts. I don't know the best approach to this. The batch query I wrote has a lot of extra noise but also the time series part of the batch query that I wrote doesn't have the facility and room number as part of the item object so it looks like it might be hard to line up. So, I'm wondering if I am just going to have to have one query per room but there could be 20+ rooms in a facility so this might cause some delay.

 

Here is what I am posting to the batch endpoint

{
  "GetFacilityId": {
    "Method": "GET",
    "Resource": "https://orf-cogenaf.ors.nih.gov/piwebapi/elements?path=\\\\ORF-COGENAF\\cGMP\\cGMP\\PET_1"
  },
  "GetRooms": {
    "Method": "GET",
    "Resource": "https://orf-cogenaf.ors.nih.gov/piwebapi/elements/{0}/elements",

    "ParentIds": [
                 "GetFacilityId"
        ],
    "Parameters": [
                 "$.GetFacilityId.Content.WebId"
        ]
  },
  "GetTimeLine": {
    "Method": "GET",

    "ParentIds":["GetRooms"],
    
    "RequestTemplate":{
      "Resource": "https://orf-cogenaf.ors.nih.gov/piwebapi/streamsets/{0}/interpolated?startTime=*-2d&endTime=*-1d&interval=60m&nameFilter=Temp"
      },
    
    "Parameters":[
      "$.GetRooms.Content.Items[*].WebId"
      ]

  }

}

What is the best approach to combine piwebapi queries and javascript to ultimately get an array of objects [{roomName: string, timeSeries:{timestamp:Date, value:number}[]}]

 

Parents Reply Children
No Data