From a8616ac46dec5c6ee49e8e614844090efa4f0ae1 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Sat, 25 Feb 2023 11:22:06 -0500 Subject: [PATCH 1/3] Update query to pull beacons from db --- iot_verifier/src/poc_report.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot_verifier/src/poc_report.rs b/iot_verifier/src/poc_report.rs index a94f6a477..4e2a81415 100644 --- a/iot_verifier/src/poc_report.rs +++ b/iot_verifier/src/poc_report.rs @@ -212,7 +212,7 @@ impl Report { from poc_report inner join entropy on poc_report.remote_entropy=entropy.data where poc_report.report_type = 'beacon' and status = 'ready' - and entropy.timestamp < $1 + and entropy.id = (select ie.id from entropy as ie where poc_report.remote_entropy = ie.data and ie.timestamp < $1 order by ie.timestamp DESC LIMIT 1) and poc_report.attempts < $2 order by poc_report.created_at asc limit 25000 From ccfc085e3c386375f2144a0d4c9ce2a0f82800d4 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Sat, 25 Feb 2023 12:54:53 -0500 Subject: [PATCH 2/3] Update query to pull beacons in iot_verifier runner --- iot_verifier/src/poc_report.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/iot_verifier/src/poc_report.rs b/iot_verifier/src/poc_report.rs index 4e2a81415..9b7a2ff50 100644 --- a/iot_verifier/src/poc_report.rs +++ b/iot_verifier/src/poc_report.rs @@ -194,7 +194,6 @@ impl Report { where E: sqlx::Executor<'c, Database = sqlx::Postgres>, { - let entropy_min_time = Utc::now() - Duration::seconds(ENTROPY_LIFESPAN); Ok(sqlx::query_as::<_, Self>( r#" select poc_report.id, @@ -210,15 +209,18 @@ impl Report { entropy.timestamp, entropy.version from poc_report - inner join entropy on poc_report.remote_entropy=entropy.data + left join entropy on entropy.id = (select ie.id + from entropy as ie + where poc_report.remote_entropy = ie.data and + poc_report.report_timestamp >= ie.timestamp and + poc_report.report_timestamp <= ie.timestamp + interval '3 minutes' + limit 1) where poc_report.report_type = 'beacon' and status = 'ready' - and entropy.id = (select ie.id from entropy as ie where poc_report.remote_entropy = ie.data and ie.timestamp < $1 order by ie.timestamp DESC LIMIT 1) - and poc_report.attempts < $2 + and poc_report.attempts < $1 order by poc_report.created_at asc limit 25000 "#, ) - .bind(entropy_min_time) .bind(BEACON_MAX_RETRY_ATTEMPTS) .fetch_all(executor) .await?) From 56357ff3f9400aeebd8addd63ddb7619fb95c83a Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Sat, 25 Feb 2023 12:57:18 -0500 Subject: [PATCH 3/3] Remove unused import --- iot_verifier/src/poc_report.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/iot_verifier/src/poc_report.rs b/iot_verifier/src/poc_report.rs index 9b7a2ff50..f67ab6211 100644 --- a/iot_verifier/src/poc_report.rs +++ b/iot_verifier/src/poc_report.rs @@ -1,4 +1,3 @@ -use crate::entropy::ENTROPY_LIFESPAN; use chrono::{DateTime, Duration, Utc}; use serde::{Deserialize, Serialize};