def get_multiple_event_list_for_organisation(
    organisation_id: int,
    project_id: int = None,  # type: ignore[assignment]
    environment_id: int = None,  # type: ignore[assignment]
    date_start: datetime | None = None,
    date_stop: datetime | None = None,
) -> list[UsageData]:
    """
    Query influx db for usage for given organisation id

    :param organisation_id: an id of the organisation to get usage for
    :param project_id: optionally filter by project id
    :param environment_id: optionally filter by an environment id

    :return: a number of requests for flags, traits, identities, environment-document
    """
    now = timezone.now()
    if date_start is None:
        date_start = now - timedelta(days=30)

    if date_stop is None:
        date_stop = now

    filters = [
        'r._measurement == "api_call"',
        f'r["organisation_id"] == "{organisation_id}"',
    ]

    if project_id:
        filters.append(f'r["project_id"] == "{project_id}"')

    if environment_id:
        filters.append(f'r["environment_id"] == "{environment_id}"')

    results = InfluxDBWrapper.influx_query_manager(
        date_start=date_start,
        date_stop=date_stop,
        filters=build_filter_string(filters),
        extra='|> aggregateWindow(every: 24h, fn: sum, timeSrc: "_start")',
    )
    if not results:
        return results  # type: ignore[no-any-return]

    dataset = [{} for _ in range(len(results[0].records))]  # type: ignore[var-annotated]

    for result in results:
        for i, record in enumerate(result.records):
            dataset[i][record.values["resource"].capitalize()] = record.values["_value"]
            dataset[i]["name"] = record.values["_time"].strftime("%Y-%m-%d")

    return dataset  # type: ignore[return-value]

    Query influx db for usage for given organisation id

    :param organisation_id: an id of the organisation to get usage for
    :param project_id: optionally filter by project id
    :param environment_id: optionally filter by an environment id

    :return: a number of requests for flags, traits, identities, environment-document
    
api/app_analytics/influxdb_wrapper.py