fix(scheduled_tasks): replace broken time parsing code with cron library

This commit is contained in:
alyssa 2025-01-02 00:27:30 +00:00
parent 8d53021863
commit 31c0253b00
2 changed files with 5 additions and 2 deletions

View file

@ -55,7 +55,10 @@ async fn cleanup_job(pool: sqlx::PgPool, bucket: Arc<s3::Bucket>) -> anyhow::Res
let mut tx = pool.begin().await?;
let image_id: Option<CleanupJobEntry> =
sqlx::query_as("select id from image_cleanup_jobs for update skip locked limit 1;")
sqlx::query_as(r#"
select id from image_cleanup_jobs
where ts < now() - interval '1 day'
for update skip locked limit 1;"#)
.fetch_optional(&mut *tx)
.await?;
if image_id.is_none() {

View file

@ -131,7 +131,7 @@ pub async fn queue_deleted_image_cleanup(ctx: AppCtx) -> anyhow::Result<()> {
.execute(
r#"
insert into image_cleanup_jobs
select id from images where
select id, now() from images where
not exists (select from image_cleanup_jobs j where j.id = images.id)
and not exists (select from systems where avatar_url = images.url)
and not exists (select from systems where banner_image = images.url)