Skip to content

Commit 7b8fd38

Browse files
committed
added campaign_find_limt to config, fixed documentation and match statement
1 parent f9f726b commit 7b8fd38

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

docs/config/dev.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
max_channels = 512
33

44
channels_find_limit = 200
5+
campaigns_find_limit = 200
56
wait_time = 500
67

78
# V4 Deprecated

docs/config/prod.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
max_channels = 512
33

44
channels_find_limit = 512
5+
campaigns_find_limit = 512
6+
57
wait_time = 40000
68

79
# V4 Deprecated

primitives/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub struct TokenInfo {
2525
pub struct Config {
2626
pub max_channels: u32,
2727
pub channels_find_limit: u32,
28+
pub campaigns_find_limit: u32,
2829
pub wait_time: u32,
2930
#[deprecated = "redundant V4 value. No aggregates are needed for V5"]
3031
pub aggr_throttle: u32,

primitives/src/sentry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ pub mod campaign {
352352
/// filters the campaigns containing a specific validator if provided
353353
pub validator: Option<ValidatorId>,
354354
/// filters the campaigns where the provided validator is a leader if true
355-
/// or if a validator isn't provided but an Auth.uid is provided (i.e. there is a auth header with token)
355+
/// if no validator is provided, but is_leader is true, it uses Auth to obtain a validator
356356
pub is_leader: Option<bool>,
357357
}
358358
}

sentry/src/db/campaign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ mod test {
586586
}
587587

588588
// Campaigns are sorted in ascending order when retrieved
589-
// Therefore every campaign in the
589+
// Therefore the last campaign inserted will come up first in results
590590
#[tokio::test]
591591
async fn it_lists_campaigns_properly() {
592592
let database = DATABASE_POOL.get().await.expect("Should get a DB pool");

sentry/src/routes/campaign.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ pub async fn campaign_list<A: Adapter>(
225225
let mut query =
226226
serde_urlencoded::from_str::<CampaignListQuery>(req.uri().query().unwrap_or(""))?;
227227

228-
query.validator = match (query.validator, req.extensions().get::<Auth>()) {
229-
(Some(validator), _) => Some(validator),
230-
(None, Some(session)) => Some(session.uid),
231-
(None, None) => None,
228+
query.validator = match (query.validator, query.is_leader, req.extensions().get::<Auth>()) {
229+
(None, Some(true), Some(session)) => Some(session.uid), // only case where session.uid is used
230+
(Some(validator), _, _) => Some(validator), // for all cases with a validator passed
231+
_ => None, // default, no filtration by validator
232232
};
233233

234-
let limit = 100; // TODO: Use a value from config
234+
let limit = app.config.campaigns_find_limit;
235235
let skip = query
236236
.page
237237
.checked_mul(limit.into())

0 commit comments

Comments
 (0)