Skip to content

Dynamic aggregations in Query #6

Open

Description

@NXXR

We decided on not storing aggregations in the DB, but dynamically compute them when requested for this we added the aggregations parameter to the infectiondata-query.

The query object should look like this:

{
  "aggregation1": [
    "Inf",
    "V2"
  ]
}

Where the first key is an arbitrary name for the aggregation that holds a list of compartment tags.
The backend querys the data and calculates the sum of all compartments containing the tags (AND connected).

The response will then contain datapoints with the aggregation name and no compartment.


FastAPI currently does not support deepObjects as query parameters but the feature is in planning.
When fastapi/fastapi#9867 is merged we can add in aggregations as deepObjects.

Alternatively a custom serialization may be possible, acting as a string query parameter.

Activity

  1. NXXR commented on Jan 24, 2025

    @NXXR
    CollaboratorAuthor

    We pivot to new idea with an aggregation flag.
    The property consists of a list of keys of the infectiondata query.
    Matching keys are aggregated to a single value for all filters provided in the query.

    i.e.:

    /scenarios/{scenarioId}/infectiondata
        ?startDate=2025-01-01
        &endDate=2025-01-01
        &nodes={CommaSeparatedListOfNodes}
        &aggregate=nodes
    

    would result in a single set of values for all nodes for each day, each compartment etc.:

    [
      {
        "date": "2025-01-01",
        "node": "aggregated",
        "group": {group1Id},
        "compartment": {MildInfectionsId},
        "percentile": 50,
        "value": {SumOfAllNodesMatchingFilter}
      },
      {
        "date": "2025-01-01",
        "node": "aggregated",
        "group": {group1Id},
        "compartment": {SevereInfectionsId},
        "percentile": 50,
        "value": {SumOfAllNodesMatchingFilter}
      },
      ...
    ]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions