pub fn split_custom_interval(
begin_datetime: DateTime<Utc>,
end_datetime: DateTime<Utc>,
retention_period: &i32,
) -> Result<QueryTimestamps, SqlError>
Expand description
Splits a date range into archived and current table queries based on retention period
§Arguments
begin_datetime
- Start of the query rangeend_datetime
- End of the query rangeretention_period
- Number of days to keep data in current table
§Returns
QueryTimestamps
containing:- archived_range: Some((begin, end)) if query needs archived data
- current_minutes: Some(minutes) if query needs current data
§Examples
let begin = Utc::now() - Duration::days(60); // 60 days ago
let end = Utc::now() - Duration::days(1); // yesterday
let retention = 30; // keep 30 days in current table
let result = split_custom_interval(begin, end, &retention)?;
// Will return:
// - archived_range: Some((60 days ago, 30 days ago))
// - current_minutes: Some(41760) // minutes for last 29 days