From 65de9abf49fefa0559f7217f5313b48bfef1c78f Mon Sep 17 00:00:00 2001 From: Matthew Plant Date: Tue, 7 May 2024 16:59:18 -0400 Subject: [PATCH] Change check_for_unprocessed_data_sets query --- .../src/boosting_oracles/data_sets.rs | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/mobile_verifier/src/boosting_oracles/data_sets.rs b/mobile_verifier/src/boosting_oracles/data_sets.rs index 80ab2b931..a9b080116 100644 --- a/mobile_verifier/src/boosting_oracles/data_sets.rs +++ b/mobile_verifier/src/boosting_oracles/data_sets.rs @@ -520,19 +520,30 @@ pub mod db { pool: &PgPool, period_end: DateTime, ) -> sqlx::Result { - Ok( - sqlx::query_scalar( - "SELECT COUNT(*) > 0 FROM data_sets WHERE time_to_use <= $1 AND status != 'processed'", - ) - .bind(period_end) - .fetch_one(pool) - .await? + Ok(sqlx::query_scalar( + "SELECT COUNT(*) > 0 FROM data_sets WHERE time_to_use <= $1 AND status != 'processed'", + ) + .bind(period_end) + .fetch_one(pool) + .await? || sqlx::query_scalar( - "SELECT COUNT(*) > 0 from hexes where urbanized IS NULL OR footfall IS NULL OR landtype IS NULL" + r#" + SELECT COUNT(*) > 0 FROM coverage_objects + WHERE inserted_at < $1 AND uuid IN ( + SELECT + DISTINCT uuid + FROM + hexes + WHERE + urbanized IS NULL + OR footfall IS NULL + OR landtype IS NULL + ) + "#, ) + .bind(period_end) .fetch_one(pool) - .await? - ) + .await?) } }