Add limit to look_back

This commit is contained in:
Joshua Coles 2024-07-27 18:41:01 +01:00
parent 3f2bbdd229
commit 7fb0ab06e1

View File

@ -12,6 +12,9 @@ enum AppError {
#[error("Toggl error: {0}")]
TogglError(#[from] toggl::TogglError),
#[error("User modified since time delta is too large. Max allowed is 90 days.")]
LookBackTooLarge,
}
struct Worker {
@ -53,6 +56,10 @@ impl Worker {
}
async fn fetch_changed_since(&mut self, look_back: TimeDelta) -> Result<(), AppError> {
if look_back > TimeDelta::days(90) {
return Err(AppError::LookBackTooLarge)
}
self.update_time_entries(Utc::now() - look_back).await
}