Skip to content

Commit 6f77d0f

Browse files
committed
sentry - units-for-slot:
- more tests - fix comments and add debug logging
1 parent 9d28c7b commit 6f77d0f

File tree

3 files changed

+376
-40
lines changed

3 files changed

+376
-40
lines changed

sentry/src/db/campaign.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,6 @@ mod test {
958958
for i in (0..generated.len()).rev() {
959959
let deposit_assets = generated[0..i].iter().copied().collect::<HashSet<_>>();
960960

961-
962961
match units_for_slot_get_campaigns(
963962
&database,
964963
Some(&deposit_assets),

sentry/src/routes/units_for_slot.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ where
127127
// We return those in the result (which means AdView would have those) but we don't actually use them
128128
// we do that in order to have the same variables as the validator, so that the `price` is the same
129129
let targeting_input_ad_slot = Some(input::AdSlot {
130-
categories: categories.clone().into_iter().collect(),
130+
categories,
131131
hostname,
132132
});
133133

@@ -181,9 +181,8 @@ async fn get_campaigns(
181181
logger: &Logger,
182182
) -> Result<Vec<Campaign>, CampaignsError> {
183183
// 1. Fetch active Campaigns: (postgres)
184-
// Creator = publisher_id
184+
// where Creator != publisher_id
185185
// if deposit asset > 0 => filter by deposit_asset
186-
// TODO: limit the amount of passable deposit assets to avoid the max query size!
187186
let active_campaigns = units_for_slot_get_campaigns(
188187
&pool,
189188
deposit_assets.as_ref(),
@@ -216,7 +215,7 @@ async fn get_campaigns(
216215
active_campaigns
217216
.iter()
218217
.find(|campaign| {
219-
debug!(logger, "Take {:?} because it's active and not exhausted, i.e. {} (remaining budget) > 0", remaining, campaign_id);
218+
debug!(logger, "Take {:?} because it's active and not exhausted, i.e. {} (remaining budget) > 0", campaign_id, remaining);
220219

221220
campaign.id == campaign_id
222221
})
@@ -294,6 +293,7 @@ async fn apply_targeting(
294293
.collect::<Vec<_>>();
295294

296295
if ad_units.is_empty() {
296+
debug!(logger, "Skipping {:?} because of no matching AdUnits types to AdSlot type {}", campaign.id, ad_slot.ad_type);
297297
None
298298
} else {
299299
let campaign_input = input_base.clone().with_campaign(campaign.clone());
@@ -328,6 +328,7 @@ async fn apply_targeting(
328328
let price = pricing_bounds.min.max(max_price);
329329

330330
if price < config.limits.units_for_slot.global_min_impression_price {
331+
debug!(logger, "Max IMPRESSION price is less than the global minium ({} < {}) for AdUnit {:?} and campaign {:?}", price, config.limits.units_for_slot.global_min_impression_price, ad_unit.ipfs, campaign.id);
331332
return None;
332333
}
333334

0 commit comments

Comments
 (0)