Skip to content

Commit ca06423

Browse files
committed
bugfix and tweaks
1 parent 84e7578 commit ca06423

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

nym-vpn-core/crates/nym-statistics/migrations/002_reports.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE pending_session_report (
22
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
3-
day DATE NOT NULL,
3+
day_utc DATE NOT NULL,
44
connection_time_ms INTEGER NOT NULL,
55
retry_attempt INTEGER NOT NULL,
66
session_duration_min INTEGER NOT NULL,

nym-vpn-core/crates/nym-statistics/src/handler/report_sending.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,15 +286,17 @@ impl InnerHandler {
286286
return;
287287
}
288288
Some(event) => {
289-
if let Some(changes) = self.update_sending_policy(event) {
289+
if let Some(new_allowed) = self.update_sending_policy(event) {
290290
// Handle policy changes
291-
if changes {
292-
timer.as_mut().set(tokio::time::sleep(SendingConfig::random_small_delay()).fuse());
291+
if new_allowed {
292+
let next_delay = SendingConfig::random_small_delay();
293+
tracing::debug!("Stats report conditions are met, trying to send in {} secs", next_delay.as_secs());
294+
timer.as_mut().set(tokio::time::sleep(next_delay).fuse());
293295

294296
} else {
295297
// We can't send, we need to abort
296298
timer.as_mut().set(tokio::time::sleep(SendingConfig::random_big_delay()).fuse());
297-
tracing::debug!("Stats report conditions not met, canceling sending task");
299+
tracing::debug!("Stats report conditions not met, canceling sending task (if it was running)");
298300
sending_task.set(Fuse::terminated());
299301
}
300302
}

nym-vpn-core/crates/nym-statistics/src/storage/sqlite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl SqliteStatsStorageManager {
4747
report: &SessionReport,
4848
) -> Result<(), StatsStorageError> {
4949
sqlx::query!(
50-
r#"INSERT INTO pending_session_report (day,
50+
r#"INSERT INTO pending_session_report (day_utc,
5151
connection_time_ms,
5252
retry_attempt,
5353
session_duration_min,
@@ -77,7 +77,7 @@ impl SqliteStatsStorageManager {
7777
Ok(sqlx::query_as(
7878
r#"SELECT
7979
id,
80-
day,
80+
day_utc,
8181
connection_time_ms,
8282
retry_attempt,
8383
session_duration_min,

0 commit comments

Comments
 (0)