feat: configurable job expiration

defaults to 30 days
This commit is contained in:
əlemi 2024-06-06 04:27:49 +02:00
parent 3123c8c1e0
commit c6d4f713ac
Signed by: alemi
GPG key ID: A4895B84D311642C
4 changed files with 5 additions and 6 deletions

View file

@ -79,6 +79,9 @@ pub struct SecurityConfig {
#[serde_inline_default(20)]
pub thread_crawl_depth: u32,
#[serde_inline_default(30)]
pub job_expiration_days: u32,
}

View file

@ -42,10 +42,6 @@ impl Model {
}
}
pub fn expired(&self) -> bool {
chrono::Utc::now() - self.published > chrono::Duration::days(7)
}
pub fn repeat(self) -> ActiveModel {
ActiveModel {
internal: sea_orm::ActiveValue::NotSet,

View file

@ -1,5 +1,5 @@
use apb::{target::Addressed, Activity, Base, Object};
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns, TransactionTrait};
use sea_orm::{sea_query::Expr, ActiveValue::{NotSet, Set}, ColumnTrait, Condition, DatabaseTransaction, EntityTrait, QueryFilter, QuerySelect, SelectColumns};
use crate::{ext::{AnyQuery, LoggableError}, model, traits::{fetch::Pull, Addresser, Fetcher, Normalizer}};
#[derive(Debug, thiserror::Error)]

View file

@ -99,7 +99,7 @@ impl JobDispatcher for Context {
},
}
if job.expired() {
if chrono::Utc::now() > job.published + chrono::Duration::days(self.cfg().security.job_expiration_days as i64) {
tracing::info!("dropping expired job {job:?}");
restart!(now);
}