mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-15 02:00:09 +00:00
fix(scheduled_tasks): replace broken time parsing code with cron library
This commit is contained in:
parent
8d53021863
commit
31c0253b00
2 changed files with 5 additions and 2 deletions
|
|
@ -55,7 +55,10 @@ async fn cleanup_job(pool: sqlx::PgPool, bucket: Arc<s3::Bucket>) -> anyhow::Res
|
||||||
let mut tx = pool.begin().await?;
|
let mut tx = pool.begin().await?;
|
||||||
|
|
||||||
let image_id: Option<CleanupJobEntry> =
|
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)
|
.fetch_optional(&mut *tx)
|
||||||
.await?;
|
.await?;
|
||||||
if image_id.is_none() {
|
if image_id.is_none() {
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ pub async fn queue_deleted_image_cleanup(ctx: AppCtx) -> anyhow::Result<()> {
|
||||||
.execute(
|
.execute(
|
||||||
r#"
|
r#"
|
||||||
insert into image_cleanup_jobs
|
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)
|
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 avatar_url = images.url)
|
||||||
and not exists (select from systems where banner_image = images.url)
|
and not exists (select from systems where banner_image = images.url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue