Add more efficient time-range calendar querying

This commit is contained in:
Lennart
2025-01-19 14:40:47 +01:00
parent 6448b23f8c
commit 7a678f5150
6 changed files with 131 additions and 4 deletions

View File

@@ -1,6 +1,13 @@
use crate::calendar::{Calendar, CalendarObject};
use crate::error::Error;
use async_trait::async_trait;
use chrono::NaiveDate;
#[derive(Default, Debug, Clone)]
pub struct CalendarQuery {
pub time_start: Option<NaiveDate>,
pub time_end: Option<NaiveDate>,
}
#[async_trait]
pub trait CalendarStore: Send + Sync + 'static {
@@ -30,6 +37,17 @@ pub trait CalendarStore: Send + Sync + 'static {
synctoken: i64,
) -> Result<(Vec<CalendarObject>, Vec<String>, i64), Error>;
/// Since the <calendar-query> rules are rather complex this function
/// is only meant to do some prefiltering
async fn calendar_query(
&self,
principal: &str,
cal_id: &str,
_query: CalendarQuery,
) -> Result<Vec<CalendarObject>, Error> {
self.get_objects(principal, cal_id).await
}
async fn get_objects(
&self,
principal: &str,