Skip to content

Commit 0baae9e

Browse files
authored
Merge pull request #456 from AmbireTech/issue-436-remove-lazy_static
Replace lazy_static with once_cell
2 parents c177437 + 04d13a7 commit 0baae9e

File tree

5 files changed

+9
-222
lines changed

5 files changed

+9
-222
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adview-manager/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ slog = { version = "^2.5.2", features = ["max_level_trace"] }
1919
# Async
2020
async-std = "^1.8"
2121
# Other
22-
lazy_static = "1.4"
22+
once_cell = "^1.8"
2323
thiserror = "^1.0"
2424
rand = "^0.8"

adview-manager/src/lib.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use adex_primitives::{
99
Address, BigNum, CampaignId, ToHex, UnifiedNum, IPFS,
1010
};
1111
use async_std::{sync::RwLock, task::block_on};
12-
use chrono::{DateTime, Utc};
13-
use lazy_static::lazy_static;
12+
use chrono::{DateTime, Duration, Utc};
1413
use num_integer::Integer;
14+
use once_cell::sync::Lazy;
1515
use rand::Rng;
1616
use reqwest::StatusCode;
1717
use serde::{Deserialize, Serialize};
@@ -33,11 +33,10 @@ const WAIT_FOR_IMPRESSION: u32 = 8000;
3333
// The number of impressions (won auctions) kept in history
3434
const HISTORY_LIMIT: u32 = 50;
3535

36-
lazy_static! {
37-
// Impression "stickiness" time: see https://github.com/AdExNetwork/adex-adview-manager/issues/65
38-
// 4 minutes allows ~4 campaigns to rotate, considering a default frequency cap of 15 minutes
39-
pub static ref IMPRESSION_STICKINESS_TIME: chrono::Duration = chrono::Duration::milliseconds(240000);
40-
}
36+
/// Impression "stickiness" time: see https://github.com/AdExNetwork/adex-adview-manager/issues/65
37+
/// 4 minutes allows ~4 campaigns to rotate, considering a default frequency cap of 15 minutes
38+
pub static IMPRESSION_STICKINESS_TIME: Lazy<Duration> =
39+
Lazy::new(|| Duration::milliseconds(240000));
4140

4241
#[derive(Serialize, Deserialize)]
4342
#[serde(rename_all = "camelCase")]
@@ -313,7 +312,7 @@ impl Manager {
313312
.rev()
314313
.find_map(|h| {
315314
if h.campaign_id == campaign_id {
316-
let last_impression: chrono::Duration = Utc::now() - h.time;
315+
let last_impression: Duration = Utc::now() - h.time;
317316

318317
u64::try_from(last_impression.num_seconds()).ok()
319318
} else {

sentry/src/event_aggregator.rs

-208
This file was deleted.

sentry/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ pub mod access;
4747
pub mod analytics_recorder;
4848
pub mod application;
4949
pub mod db;
50-
// TODO AIP#61: remove the even aggregator once we've taken out the logic for AIP#61
51-
// pub mod event_aggregator;
52-
// TODO AIP#61: Remove even reducer or alter depending on our needs
53-
// pub mod event_reducer;
5450
pub mod payout;
5551
pub mod spender;
5652

0 commit comments

Comments
 (0)