diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 4945281cc..3425a795d 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -27,7 +27,7 @@ use crate::{ }, }; use ::url::Url; -use chrono::{TimeDelta, Utc}; +use chrono::Utc; use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods}; use diesel_async::RunQueryDsl; use std::collections::HashSet; @@ -105,12 +105,7 @@ impl Post { .filter(post::deleted.eq(false)) .filter(post::removed.eq(false)) .filter( - post::published.ge( - Utc::now().naive_utc() - - TimeDelta::try_days(SITEMAP_DAYS) - .ok_or("TimeDelta out of bounds") - .map_err(|e| Error::QueryBuilderError(e.into()))?, - ), + post::published.ge(Utc::now().naive_utc() - SITEMAP_DAYS.expect("TimeDelta out of bounds")), ) .order(post::published.desc()) .limit(SITEMAP_LIMIT) diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 038ab129a..9a89902e7 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -6,7 +6,7 @@ use crate::{ SortType, }; use anyhow::Context; -use chrono::{DateTime, Utc}; +use chrono::{DateTime, TimeDelta, Utc}; use deadpool::Runtime; use diesel::{ helper_types::AsExprOf, @@ -51,7 +51,7 @@ use url::Url; const FETCH_LIMIT_DEFAULT: i64 = 10; pub const FETCH_LIMIT_MAX: i64 = 50; pub const SITEMAP_LIMIT: i64 = 50000; -pub const SITEMAP_DAYS: i64 = 31; +pub const SITEMAP_DAYS: Option = TimeDelta::try_days(31); pub const RANK_DEFAULT: f64 = 0.0001; pub type ActualDbPool = Pool; diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index 8ae186b47..ff2a68e3c 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -333,7 +333,7 @@ impl InstanceWorker { last_fetch: DateTime, ) -> Result<(HashMap>, DateTime)> { let new_last_fetch = - Utc::now() - chrono::TimeDelta::try_seconds(10).context("TimeDelta out of bounds")?; // update to time before fetch to ensure overlap. subtract 10s to ensure overlap even if published date is not exact + Utc::now() - chrono::TimeDelta::try_seconds(10).expect("TimeDelta out of bounds"); // update to time before fetch to ensure overlap. subtract 10s to ensure overlap even if published date is not exact Ok(( CommunityFollowerView::get_instance_followed_community_inboxes(pool, instance_id, last_fetch) .await?