Skip to content

It is difficult to do parameter filters in RISE #79

Description

@C-Loftus

I was chatting with John late last week and I think we have a blocker if we want to keep proxying and some general challenges with filtering by parameters:

Frontend-driven challenges

  • We need to be able to fetch the latest reservoir storage for all reservoirs for the teacups;
    • However, this is 140 different parameters and RISE rejects it as being too much fetched data whether as separate queries or all in the same URL
  • This essentially means there is no way to get this with a realtime proxy unless we fetch and add contrived time.sleep to stagger it
    • this would make the UI far too slow

So essentially my only way to get this info is to schedule cache the params ahead of time by scheduling them; then after they are cached we no longer need to ping RISE and thus won't get the issue
https://github.com/dbader/schedule

However this is messy and running a scheduled prefetch cache job is not ideal

General parameter filter issues

In general filtering on parameters is difficult in RISE.

In RISE there are multiple different endpoints such as catalogItems, catalogRecords, parameters, and locations.

You can include catalogItems with the locations by doing the following, and you can filter out locations by certain parameters, but I do not believe there is a way to include the parameters joined with the locations in the actual response.

The issue is that if you filter with f"parameterId%5B%5D={prop}&" it returns any location that has that param, so I then need a way of filtering out the param from the location.

        base_url = "https://data.usbr.gov/rise/api/location?order[id]=asc&include=catalogRecords.catalogItems"
        hasTimeseriesData = "itemStructureId=1"
        if only_include_locations_with_data:
            base_url += f"&{hasTimeseriesData}"

        if properties_to_filter_by:
            base_url += "&"
            for prop in properties_to_filter_by:
                assert isinstance(prop, str)
                base_url += f"parameterId%5B%5D={prop}&"
            base_url = base_url.removesuffix("&")

Because I only get the catalog items and not the actual parameter response, there is no good way to filter without doing another fetch for every parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RISEPertaining to the USBR RISE APIupstreamPertaining to an issue with an upstream API out of our control

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions