def get_events_for_organisation(
    organisation_id: id,  # type: ignore[valid-type]
    date_start: datetime | None = None,
    date_stop: datetime | None = None,
) -> int:
    """
    Query influx db for usage for given organisation id

    :param organisation_id: an id of the organisation to get usage for
    :return: a number of request counts for organisation
    """
    now = timezone.now()
    if date_start is None:
        date_start = now - timedelta(days=30)

    if date_stop is None:
        date_stop = now

    result = InfluxDBWrapper.influx_query_manager(
        filters=build_filter_string(
            [
                'r._measurement == "api_call"',
                'r["_field"] == "request_count"',
                f'r["organisation_id"] == "{organisation_id}"',
            ]
        ),
        drop_columns=(
            "organisation",
            "project",
            "project_id",
            "environment",
            "environment_id",
        ),
        extra="|> sum()",
        date_start=date_start,
        date_stop=date_stop,
    )

    total = 0
    for table in result:
        for record in table.records:
            total += record.get_value()

    return total

    Query influx db for usage for given organisation id

    :param organisation_id: an id of the organisation to get usage for
    :return: a number of request counts for organisation
    
api/app_analytics/influxdb_wrapper.py