Skip to content

GET /v5/campaign/list #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 30, 2021
Merged
1 change: 1 addition & 0 deletions docs/config/dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
max_channels = 512

channels_find_limit = 200
campaigns_find_limit = 200
wait_time = 500

# V4 Deprecated
Expand Down
2 changes: 2 additions & 0 deletions docs/config/prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
max_channels = 512

channels_find_limit = 512
campaigns_find_limit = 512

wait_time = 40000

# V4 Deprecated
Expand Down
1 change: 1 addition & 0 deletions primitives/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct TokenInfo {
pub struct Config {
pub max_channels: u32,
pub channels_find_limit: u32,
pub campaigns_find_limit: u32,
pub wait_time: u32,
#[deprecated = "redundant V4 value. No aggregates are needed for V5"]
pub aggr_throttle: u32,
Expand Down
3 changes: 3 additions & 0 deletions primitives/src/sentry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ pub mod campaign {
pub creator: Option<Address>,
/// filters the campaigns containing a specific validator if provided
pub validator: Option<ValidatorId>,
/// filters the campaigns where the provided validator is a leader if true
/// if no validator is provided, but is_leader is true, it uses Auth to obtain a validator
pub is_leader: Option<bool>,
}
}

Expand Down
22 changes: 20 additions & 2 deletions sentry/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use deadpool_postgres::{Manager, ManagerConfig, RecyclingMethod};
use redis::aio::MultiplexedConnection;
use std::env;
use tokio_postgres::NoTls;
use std::{env, str::FromStr};
use tokio_postgres::{
types::{accepts, FromSql, Type},
NoTls,
};

use lazy_static::lazy_static;

Expand Down Expand Up @@ -53,6 +56,21 @@ lazy_static! {
};
}

pub struct TotalCount(pub u64);
impl<'a> FromSql<'a> for TotalCount {
fn from_sql(
ty: &Type,
raw: &'a [u8],
) -> Result<Self, Box<dyn std::error::Error + Sync + Send>> {
let str_slice = <&str as FromSql>::from_sql(ty, raw)?;

Ok(Self(u64::from_str(str_slice)?))
}

// Use a varchar or text, since otherwise `int8` fails deserialization
accepts!(VARCHAR, TEXT);
}

pub async fn redis_connection(url: &str) -> Result<MultiplexedConnection, RedisError> {
let client = redis::Client::open(url)?;

Expand Down
Loading