def METHOD_NAME(
    request: HttpRequest,
    params: Mapping[str, Any],
    default_interval: Union[None, str],
    error: Exception,
    top_events: int = 0,
) -> int:
    date_range = params["end"] - params["start"]
    if default_interval is None:
        default_interval = get_interval_from_range(date_range, False)
    interval = parse_stats_period(request.GET.get("interval", default_interval))
    if interval is None:
        interval = timedelta(hours=1)
    validate_interval(interval, error, date_range, top_events)
    return int(interval.total_seconds())