Skip to content

Commit 692bf08

Browse files
authored
Merge pull request #430 from AdExNetwork/issue-429-campaign-list
GET /v5/campaign/list
2 parents 20e123e + 7b8fd38 commit 692bf08

File tree

10 files changed

+407
-33
lines changed

10 files changed

+407
-33
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ pub mod campaign {
351351
pub creator: Option<Address>,
352352
/// filters the campaigns containing a specific validator if provided
353353
pub validator: Option<ValidatorId>,
354+
/// filters the campaigns where the provided validator is a leader if true
355+
/// if no validator is provided, but is_leader is true, it uses Auth to obtain a validator
356+
pub is_leader: Option<bool>,
354357
}
355358
}
356359

sentry/src/db.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use deadpool_postgres::{Manager, ManagerConfig, RecyclingMethod};
22
use redis::aio::MultiplexedConnection;
3-
use std::env;
4-
use tokio_postgres::NoTls;
3+
use std::{env, str::FromStr};
4+
use tokio_postgres::{
5+
types::{accepts, FromSql, Type},
6+
NoTls,
7+
};
58

69
use lazy_static::lazy_static;
710

@@ -53,6 +56,21 @@ lazy_static! {
5356
};
5457
}
5558

59+
pub struct TotalCount(pub u64);
60+
impl<'a> FromSql<'a> for TotalCount {
61+
fn from_sql(
62+
ty: &Type,
63+
raw: &'a [u8],
64+
) -> Result<Self, Box<dyn std::error::Error + Sync + Send>> {
65+
let str_slice = <&str as FromSql>::from_sql(ty, raw)?;
66+
67+
Ok(Self(u64::from_str(str_slice)?))
68+
}
69+
70+
// Use a varchar or text, since otherwise `int8` fails deserialization
71+
accepts!(VARCHAR, TEXT);
72+
}
73+
5674
pub async fn redis_connection(url: &str) -> Result<MultiplexedConnection, RedisError> {
5775
let client = redis::Client::open(url)?;
5876

0 commit comments

Comments
 (0)