prepare to remove old log, in favor of activities
Some checks failed
CI/CD Pipeline / test (push) Successful in 17m41s
CI/CD Pipeline / deploy-staging (push) Has been cancelled
CI/CD Pipeline / deploy-main (push) Has been cancelled

This commit is contained in:
2025-05-12 22:29:34 +02:00
parent f86d2f6307
commit e4a8caf632
3 changed files with 20 additions and 92 deletions

View File

@@ -1,7 +1,7 @@
use std::ops::DerefMut;
use super::{role::Role, user::User};
use chrono::{DateTime, Local, NaiveDateTime, TimeZone, Utc};
use chrono::{DateTime, Duration, Local, NaiveDateTime, TimeZone, Utc};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, Sqlite, SqlitePool, Transaction};
@@ -46,6 +46,15 @@ impl ActivityBuilder {
}
}
#[must_use]
pub fn keep_until_days(self, days: i64) -> Self {
let now = Utc::now().naive_utc();
Self {
keep_until: Some(now + Duration::days(days)),
..self
}
}
pub async fn save(self, db: &SqlitePool) {
Activity::create(db, &self.text, &self.relevant_for, self.keep_until).await;
}