Skip to content

Commit

Permalink
fix: pass correct page in gov pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszjasiuk committed Jul 9, 2024
1 parent f9a4d2f commit cf8ca82
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 32 deletions.
42 changes: 35 additions & 7 deletions orm/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,59 @@
// @generated automatically by Diesel CLI.

pub mod sql_types {
#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "governance_kind"))]
pub struct GovernanceKind;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "governance_result"))]
pub struct GovernanceResult;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "governance_tally_type"))]
pub struct GovernanceTallyType;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "transaction_kind"))]
pub struct TransactionKind;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "transaction_result"))]
pub struct TransactionResult;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "validator_state"))]
pub struct ValidatorState;

#[derive(diesel::query_builder::QueryId, std::fmt::Debug, diesel::sql_types::SqlType)]
#[derive(
diesel::query_builder::QueryId,
std::fmt::Debug,
diesel::sql_types::SqlType,
)]
#[diesel(postgres_type(name = "vote_kind"))]
pub struct VoteKind;
}
Expand Down
4 changes: 1 addition & 3 deletions parameters/src/services/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use namada_sdk::queries::RPC;
use namada_sdk::rpc::{
self, get_token_total_supply, get_total_staked_tokens, query_storage_value,
};
use namada_sdk::token::{
Amount as NamadaSdkAmount,
};
use namada_sdk::token::Amount as NamadaSdkAmount;
use shared::balance::Amount;
use shared::block::Epoch;
use shared::gas::GasPrice;
Expand Down
7 changes: 4 additions & 3 deletions shared/src/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ use std::fmt::Display;

use bigdecimal::BigDecimal;
use fake::Fake;
use namada_sdk::token::Amount as NamadaAmount;
use namada_sdk::token::DenominatedAmount as NamadaDenominatedAmount;
use namada_sdk::token::Denomination as NamadaDenomination;
use namada_sdk::token::{
Amount as NamadaAmount, DenominatedAmount as NamadaDenominatedAmount,
Denomination as NamadaDenomination,
};

use crate::id::Id;

Expand Down
10 changes: 4 additions & 6 deletions webserver/src/dto/governance.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use serde::{Deserialize, Serialize};
use validator::Validate;

use super::utils::Pagination;

#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum ProposalStatus {
Expand All @@ -23,15 +21,15 @@ pub enum ProposalKind {

#[derive(Clone, Serialize, Deserialize, Validate)]
pub struct ProposalQueryParams {
#[serde(flatten)]
pub pagination: Option<Pagination>,
#[validate(range(min = 1, max = 10000))]
pub page: Option<u64>,
pub status: Option<ProposalStatus>,
pub kind: Option<ProposalKind>,
pub pattern: Option<String>,
}

#[derive(Clone, Serialize, Deserialize, Validate)]
pub struct ProposalVotesQueryparams {
#[serde(flatten)]
pub pagination: Option<Pagination>,
#[validate(range(min = 1, max = 10000))]
pub page: Option<u64>,
}
1 change: 0 additions & 1 deletion webserver/src/dto/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
pub mod governance;
pub mod pos;
pub mod utils;
8 changes: 0 additions & 8 deletions webserver/src/dto/utils.rs

This file was deleted.

4 changes: 2 additions & 2 deletions webserver/src/handler/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn get_governance_proposals(
Query(query): Query<ProposalQueryParams>,
State(state): State<CommonState>,
) -> Result<Json<PaginatedResponse<Vec<Proposal>>>, ApiError> {
let page = query.pagination.map(|p| p.page).unwrap_or(1);
let page = query.page.unwrap_or(1);
let (proposals, total_pages, total_items) = state
.gov_service
.find_governance_proposals(
Expand Down Expand Up @@ -57,7 +57,7 @@ pub async fn get_governance_proposal_votes(
Query(query): Query<ProposalVotesQueryparams>,
State(state): State<CommonState>,
) -> Result<Json<PaginatedResponse<Vec<ProposalVote>>>, ApiError> {
let page = query.pagination.map(|p| p.page).unwrap_or(1);
let page = query.page.unwrap_or(1);
let (proposal_votes, total_pages, total_votes) = state
.gov_service
.find_governance_proposal_votes(proposal_id, page)
Expand Down
3 changes: 1 addition & 2 deletions webserver/src/response/gas.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use orm::gas::{GasDb, GasPriceDb};
use serde::{Deserialize, Serialize};

use crate::service::utils::raw_amount_to_nam;

use super::transaction::TransactionKind;
use crate::service::utils::raw_amount_to_nam;

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down

0 comments on commit cf8ca82

Please sign in to comment.