Skip to content

Commit

Permalink
add totalCount to VotePlanStatusConnection too
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Mar 2, 2021
1 parent cd977c8 commit 5428789
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jormungandr/src/explorer/graphql/mod.rs
Expand Up @@ -13,7 +13,8 @@ use self::connections::{
use self::error::ErrorKind;
use self::scalars::{
BlockCount, ChainLength, ExternalProposalId, IndexCursor, NonZero, PayloadType, PoolCount,
PoolId, PublicKey, Slot, TransactionCount, Value, VoteOptionRange, VotePlanId, Weight,
PoolId, PublicKey, Slot, TransactionCount, Value, VoteOptionRange, VotePlanId,
VotePlanStatusCount, Weight,
};
use super::indexing::{
BlockProducer, EpochData, ExplorerAddress, ExplorerBlock, ExplorerTransaction, StakePoolData,
Expand Down Expand Up @@ -206,7 +207,9 @@ impl Branch {
last: Option<i32>,
before: Option<String>,
after: Option<String>,
) -> FieldResult<Connection<IndexCursor, VotePlanStatus, EmptyFields, EmptyFields>> {
) -> FieldResult<
Connection<IndexCursor, VotePlanStatus, ConnectionFields<VotePlanStatusCount>, EmptyFields>,
> {
let mut vote_plans = self.state.state().get_vote_plans();

vote_plans.sort_unstable_by_key(|(id, _data)| id.clone());
Expand Down Expand Up @@ -239,8 +242,13 @@ impl Branch {
};

let (range, page_meta) = compute_interval(boundaries, pagination_arguments)?;
let mut connection =
Connection::new(page_meta.has_previous_page, page_meta.has_next_page);
let mut connection = Connection::with_additional_fields(
page_meta.has_previous_page,
page_meta.has_next_page,
ConnectionFields {
total_count: page_meta.total_count,
},
);

let edges = match range {
PaginationInterval::Empty => vec![],
Expand Down
1 change: 1 addition & 0 deletions jormungandr/src/explorer/graphql/scalars.rs
Expand Up @@ -83,6 +83,7 @@ impl ScalarType for Value {
pub type BlockCount = u64;
pub type TransactionCount = u64;
pub type PoolCount = u64;
pub type VotePlanStatusCount = u64;

pub struct PublicKey(pub String);

Expand Down

0 comments on commit 5428789

Please sign in to comment.