Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
/// or if a validator isn't provided but an Auth.uid is provided (i.e. there is a auth header with token)
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