Auto compact at ~90% (#5292)
Users now hit a window exceeded limit and they usually don't know what to do. This starts auto compact at ~90% of the window.
This commit is contained in:
@@ -142,9 +142,9 @@ impl RateLimitWarningState {
|
||||
fn take_warnings(
|
||||
&mut self,
|
||||
secondary_used_percent: Option<f64>,
|
||||
secondary_window_minutes: Option<u64>,
|
||||
secondary_window_minutes: Option<i64>,
|
||||
primary_used_percent: Option<f64>,
|
||||
primary_window_minutes: Option<u64>,
|
||||
primary_window_minutes: Option<i64>,
|
||||
) -> Vec<String> {
|
||||
let reached_secondary_cap =
|
||||
matches!(secondary_used_percent, Some(percent) if percent == 100.0);
|
||||
@@ -195,12 +195,14 @@ impl RateLimitWarningState {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_limits_duration(windows_minutes: u64) -> String {
|
||||
const MINUTES_PER_HOUR: u64 = 60;
|
||||
const MINUTES_PER_DAY: u64 = 24 * MINUTES_PER_HOUR;
|
||||
const MINUTES_PER_WEEK: u64 = 7 * MINUTES_PER_DAY;
|
||||
const MINUTES_PER_MONTH: u64 = 30 * MINUTES_PER_DAY;
|
||||
const ROUNDING_BIAS_MINUTES: u64 = 3;
|
||||
pub(crate) fn get_limits_duration(windows_minutes: i64) -> String {
|
||||
const MINUTES_PER_HOUR: i64 = 60;
|
||||
const MINUTES_PER_DAY: i64 = 24 * MINUTES_PER_HOUR;
|
||||
const MINUTES_PER_WEEK: i64 = 7 * MINUTES_PER_DAY;
|
||||
const MINUTES_PER_MONTH: i64 = 30 * MINUTES_PER_DAY;
|
||||
const ROUNDING_BIAS_MINUTES: i64 = 3;
|
||||
|
||||
let windows_minutes = windows_minutes.max(0);
|
||||
|
||||
if windows_minutes <= MINUTES_PER_DAY.saturating_add(ROUNDING_BIAS_MINUTES) {
|
||||
let adjusted = windows_minutes.saturating_add(ROUNDING_BIAS_MINUTES);
|
||||
|
||||
Reference in New Issue
Block a user