Skip to content

Commit c2d4f0b

Browse files
committed
sentry - units-for-slot tests
- primitives - config - fix example - sentry - units-for-slot - fix logging
1 parent 70a6825 commit c2d4f0b

File tree

6 files changed

+628
-70
lines changed

6 files changed

+628
-70
lines changed

primitives/examples/get_cfg_response.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fn main() {
2525
"creators_whitelist": [
2626
"0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F",
2727
"0xDd589B43793934EF6Ad266067A0d1D4896b0dff0",
28+
"0xE882ebF439207a70dDcCb39E13CA8506c9F45fD9",
2829
"0x541b401362Ea1D489D322579552B099e801F3632"
2930
],
3031
"validators_whitelist": [
@@ -70,7 +71,7 @@ fn main() {
7071
"limits": {
7172
"units_for_slot": {
7273
"max_campaigns_earning_from": 25,
73-
"global_min_impression_price": "1000000"
74+
"global_min_impression_price": "10000"
7475
}
7576
}
7677
});

primitives/src/campaign.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,13 @@ mod pricing {
255255

256256
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
257257
pub struct Pricing {
258+
/// The minimum payable amount for a single event
258259
pub min: UnifiedNum,
260+
/// The maximum payable amount for a single event
259261
pub max: UnifiedNum,
260262
}
261263

264+
/// The pricing bounds (minimum and maximum payable amount) per event type for 1 event.
262265
#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
263266
#[serde(transparent)]
264267
pub struct PricingBounds(HashMap<EventType, Pricing>);

primitives/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ pub struct Config {
181181
#[serde(rename = "chain")]
182182
pub chains: HashMap<String, ChainInfo>,
183183
pub platform: PlatformConfig,
184+
/// Any limits applied to Sentry or Validator.
184185
pub limits: Limits,
185186
}
186187

sentry/src/db/campaign.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ pub async fn get_campaign_ids_by_channel(
183183
Ok(campaign_ids)
184184
}
185185

186+
/// Updates the campaign fields:
187+
/// budget, validators, title, pricing_bounds, event_submission, ad_units, targeting_rules
186188
/// ```text
187189
/// UPDATE campaigns SET budget = $1, validators = $2, title = $3, pricing_bounds = $4, event_submission = $5, ad_units = $6, targeting_rules = $7
188190
/// FROM channels WHERE campaigns.id = $8 AND campaigns.channel_id=channels.id

sentry/src/routes/units_for_slot.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,13 @@ async fn get_campaigns(
215215
active_campaigns
216216
.iter()
217217
.find(|campaign| {
218-
debug!(logger, "Take {:?} because it's active and not exhausted, i.e. {} (remaining budget) > 0", campaign_id, remaining);
218+
if campaign.id == campaign_id {
219+
debug!(logger, "Take {:?} because it's active and not exhausted, i.e. {:?} (remaining budget) > 0", campaign_id, remaining);
219220

220-
campaign.id == campaign_id
221+
true
222+
} else {
223+
false
224+
}
221225
})
222226
.cloned()
223227
} else {
@@ -321,7 +325,7 @@ async fn apply_targeting(
321325
return None;
322326
}
323327

324-
let max_price = match output.price.get(IMPRESSION.as_str()) {
328+
let max_price = match output.price.get(&IMPRESSION) {
325329
Some(output_price) => *output_price.min(&pricing_bounds.max),
326330
None => pricing_bounds.max,
327331
};

0 commit comments

Comments
 (0)