Skip to content

Commit 188cd6a

Browse files
committed
add: sentry impl
1 parent 508b339 commit 188cd6a

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

primitives/src/channel.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ pub struct Channel {
9898
#[serde(default)]
9999
pub targeting_rules: Vec<Rule>,
100100
pub spec: ChannelSpec,
101+
#[serde(default)]
102+
pub exhausted: Vec<bool>
103+
}
104+
105+
pub fn channel_exhausted(channel: &Channel) -> bool {
106+
channel.exhausted.len() == 2 && channel.exhausted.iter().all(|&x| x == true)
101107
}
102108

103109
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
@@ -387,6 +393,7 @@ pub mod postgres {
387393
valid_until: row.get("valid_until"),
388394
targeting_rules: row.get::<_, Json<Vec<Rule>>>("targeting_rules").0,
389395
spec: row.get::<_, Json<ChannelSpec>>("spec").0,
396+
exhausted: row.get("exhausted"),
390397
}
391398
}
392399
}

primitives/src/util/tests/prep_db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ lazy_static! {
8282
ad_units: vec![],
8383
pricing_bounds: Some(PricingBounds {impression: None, click: Some(Pricing { max: 0.into(), min: 0.into()})}),
8484
},
85+
exhausted: Default::default(),
8586
}
8687
};
8788

sentry/migrations/20190806011140_initial-tables/up.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CREATE TABLE channels
66
deposit_amount VARCHAR(255) NOT NULL,
77
valid_until TIMESTAMP(2) WITH TIME ZONE NOT NULL,
88
spec JSONB NOT NULL,
9+
exhausted BOOLEAN[2]
910

1011
PRIMARY KEY (id)
1112
);

0 commit comments

Comments
 (0)