Skip to content

Commit 2e561d2

Browse files
committed
Merge branch 'aip-61-adex-v5' into get-leaf-route
2 parents 4044b10 + a7db507 commit 2e561d2

21 files changed

+1858
-3442
lines changed

Cargo.lock

Lines changed: 1 addition & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.harness.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ services:
1313
POSTGRES_USER: 'postgres'
1414
POSTGRES_PASSWORD: 'postgres'
1515
# harness_* databases are used by the `test_harness` crate for testing
16-
# `sentry_leader` is the default database used by `sentry` for running tests
16+
# `sentry_leader` is the default database used by `sentry` for running tests and the leader
17+
# `sentry_leader` is for running the local follower when maunally testing
1718
# `primitives` is used for running tests in the `primitives` crate
18-
POSTGRES_MULTIPLE_DATABASES: harness_leader,harness_follower,sentry_leader,primitives
19+
POSTGRES_MULTIPLE_DATABASES: harness_leader,harness_follower,sentry_leader,sentry_follower,primitives
1920
networks:
2021
- adex-external
2122

primitives/examples/channel_pay_request.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use primitives::sentry::ChannelPayRequest;
22
use serde_json::json;
3-
use std::str::FromStr;
43

54
fn main() {
65
let channel_pay_json = json!({

primitives/src/analytics.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ pub mod query;
103103
#[derive(Debug, Serialize, Deserialize, Clone)]
104104
#[serde(rename_all = "camelCase")]
105105
pub struct AnalyticsQuery {
106+
/// Default: `100`
106107
#[serde(default = "default_limit")]
107108
pub limit: u32,
109+
/// Default: [`EventType::Impression`]
108110
#[serde(default = "default_event_type")]
109111
pub event_type: EventType,
112+
// Default: [`Metric::Count`]
110113
#[serde(default = "default_metric")]
111114
pub metric: Metric,
112115
pub segment_by: Option<AllowedKey>,
@@ -125,6 +128,28 @@ pub struct AnalyticsQuery {
125128
pub chains: Vec<ChainId>,
126129
}
127130

131+
impl Default for AnalyticsQuery {
132+
fn default() -> Self {
133+
Self {
134+
limit: default_limit(),
135+
event_type: default_event_type(),
136+
metric: default_metric(),
137+
segment_by: None,
138+
time: Time::default(),
139+
campaign_id: None,
140+
ad_unit: None,
141+
ad_slot: None,
142+
ad_slot_type: None,
143+
advertiser: None,
144+
publisher: None,
145+
hostname: None,
146+
country: None,
147+
os_name: None,
148+
chains: Vec::new(),
149+
}
150+
}
151+
}
152+
128153
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Display, Hash, Eq)]
129154
#[serde(untagged, into = "String", from = "String")]
130155
pub enum OperatingSystem {

primitives/src/analytics/query.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ pub struct Time {
107107
// #[serde(default = "default_timezone_utc")]
108108
// pub timezone: Tz,//: chrono::TimeZone,
109109
}
110+
111+
impl Default for Time {
112+
fn default() -> Self {
113+
let timeframe = Timeframe::Day;
114+
let start = DateHour::now() - &timeframe;
115+
116+
Self {
117+
timeframe,
118+
start,
119+
end: None,
120+
}
121+
}
122+
}
123+
110124
mod de {
111125
use crate::{analytics::Timeframe, sentry::DateHour};
112126

@@ -211,6 +225,12 @@ mod test {
211225
let empty = json!({});
212226

213227
let time = from_value::<Time>(empty).expect("Should use defaults on empty JSON");
228+
let default = Time::default();
229+
pretty_assertions::assert_eq!(
230+
time,
231+
default,
232+
"Default should generate the same as the default deserialization values!"
233+
);
214234
pretty_assertions::assert_eq!(
215235
time,
216236
Time {

sentry/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ hex = "0.4"
4141
# CLI
4242
clap = { version = "3", features = ["cargo"] }
4343
# Server
44-
axum = { version = "0.5", features = ["http1", "http2"] }
44+
axum = { version = "0.5", features = ["http1", "http2", "headers"] }
4545
axum-server = { version = "0.4", features = ["tls-rustls"] }
4646
tower = "0.4"
4747
tower-http = { version = "0.3", features = ["cors"] }
4848
tokio = { version = "1", features = ["macros", "time", "rt-multi-thread", "signal"] }
49-
hyper = { version = "0.14", features = ["stream", "runtime", "http1", "http2", "server"] }
50-
simple-hyper-server-tls = { version = "0.3", features = ["tls-rustls"] }
51-
regex = "1"
49+
5250
# Database
5351
redis = { version = "0.21", features = ["aio", "tokio-comp"] }
5452
deadpool = "0.9"
@@ -85,3 +83,6 @@ pretty_assertions = "1"
8583

8684
primitives = { path = "../primitives", features = ["postgres", "test-util"] }
8785
adapter = { version = "0.2", path = "../adapter", features = ["test-util"] }
86+
87+
# we only require `hyper` for `hyper::body::to_bytes` function
88+
hyper = { version = "0.14", default-features = false }

0 commit comments

Comments
 (0)