Skip to content

Commit

Permalink
Fix interval
Browse files Browse the repository at this point in the history
  • Loading branch information
linuskendall committed Apr 20, 2023
1 parent f2cbafd commit b8efdf2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nft_ingester/src/tasks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cadence_macros::{is_global_default_set, statsd_count, statsd_histogram};
use chrono::{Duration, NaiveDateTime, Utc};
use crypto::{digest::Digest, sha2::Sha256};
use digital_asset_types::dao::{sea_orm_active_enums::TaskStatus, tasks};
use log::{debug, error, warn};
use log::{debug, info, error, warn};
use sea_orm::{
entity::*, query::*, sea_query::Expr, ActiveValue::Set, ColumnTrait, DatabaseConnection,
DeleteResult, SqlxPostgresConnector,
Expand Down Expand Up @@ -277,8 +277,8 @@ impl TaskManager {
}

pub async fn purge_old_tasks(conn: &DatabaseConnection, task_max_age: time::Duration) -> Result<DeleteResult, IngesterError> {
let interval = format!("interval {} seconds", task_max_age.as_secs());
let cod = Expr::cust_with_values("NOW() - created_at::timestamp > ?", [interval]);
let interval = format!("NOW() - created_at::timestamp > interval '{} seconds'", task_max_age.as_secs());
let cod = Expr::cust(&interval);
tasks::Entity::delete_many()
.filter(Condition::all().add(cod))
.exec(conn)
Expand Down Expand Up @@ -376,7 +376,7 @@ impl TaskManager {
let delete_res = TaskManager::purge_old_tasks(&conn, purge_time).await;
match delete_res {
Ok(res) => {
debug!("deleted {} tasks entries", res.rows_affected);
info!("deleted {} tasks entries", res.rows_affected);
metric! {
statsd_count!("ingester.bgtask.purged_tasks", i64::try_from(res.rows_affected).unwrap_or(1));
}
Expand Down

0 comments on commit b8efdf2

Please sign in to comment.