From ed178cba816eaf971b85f4548b0e61c52a0faee9 Mon Sep 17 00:00:00 2001 From: Leonid Tyurin Date: Thu, 12 Dec 2024 20:07:47 +0700 Subject: [PATCH] fix: adjust order_by --- .../src/repository/addresses.rs | 14 +++++++------- .../src/services/multichain_aggregator.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs b/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs index 60e0bd0f2..431f28f25 100644 --- a/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs +++ b/multichain-aggregator/multichain-aggregator-logic/src/repository/addresses.rs @@ -62,22 +62,22 @@ where pub async fn search_by_query_paginated( db: &C, q: &str, - page_token: Option<(ChainId, AddressAlloy)>, + page_token: Option<(AddressAlloy, ChainId)>, limit: u64, -) -> Result<(Vec
, Option<(ChainId, AddressAlloy)>), ServiceError> +) -> Result<(Vec
, Option<(AddressAlloy, ChainId)>), ServiceError> where C: ConnectionTrait, { - let page_token = page_token.unwrap_or((ChainId::MIN, AddressAlloy::ZERO)); + let page_token = page_token.unwrap_or((AddressAlloy::ZERO, ChainId::MIN)); let mut query = Entity::find() .filter( Expr::tuple([ - Column::ChainId.into_simple_expr(), Column::Hash.into_simple_expr(), + Column::ChainId.into_simple_expr(), ]) .gte(Expr::tuple([ - page_token.0.into(), - page_token.1.as_slice().into(), + page_token.0.as_slice().into(), + page_token.1.into(), ])), ) .order_by_asc(Column::Hash) @@ -109,7 +109,7 @@ where match addresses.get(limit as usize) { Some(a) => Ok(( addresses[0..limit as usize].to_vec(), - Some((a.chain_id, a.hash)), + Some((a.hash, a.chain_id)), )), None => Ok((addresses, None)), } diff --git a/multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs b/multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs index cbbdb7fd9..b8d0762c4 100644 --- a/multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs +++ b/multichain-aggregator/multichain-aggregator-server/src/services/multichain_aggregator.rs @@ -80,7 +80,7 @@ impl MultichainAggregatorService for MultichainAggregator { ) -> Result, Status> { let inner = request.into_inner(); - let page_token: Option<(logic::ChainId, alloy_primitives::Address)> = + let page_token: Option<(alloy_primitives::Address, logic::ChainId)> = inner.page_token.map(parse_query_2).transpose()?; let page_size = self.normalize_page_size(inner.page_size); @@ -98,8 +98,8 @@ impl MultichainAggregatorService for MultichainAggregator { Ok(Response::new(ListAddressesResponse { addresses: addresses.into_iter().map(|a| a.into()).collect(), - pagination: next_page_token.map(|(c, a)| Pagination { - page_token: format!("{},{}", c, a.to_checksum(None)), + pagination: next_page_token.map(|(a, c)| Pagination { + page_token: format!("{},{}", a.to_checksum(None), c), page_size, }), }))