Skip to content

Commit

Permalink
fix: adjust order_by
Browse files Browse the repository at this point in the history
  • Loading branch information
lok52 committed Dec 12, 2024
1 parent bf0df8b commit ed178cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,22 @@ where
pub async fn search_by_query_paginated<C>(
db: &C,
q: &str,
page_token: Option<(ChainId, AddressAlloy)>,
page_token: Option<(AddressAlloy, ChainId)>,
limit: u64,
) -> Result<(Vec<Address>, Option<(ChainId, AddressAlloy)>), ServiceError>
) -> Result<(Vec<Address>, 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)
Expand Down Expand Up @@ -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)),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl MultichainAggregatorService for MultichainAggregator {
) -> Result<Response<ListAddressesResponse>, 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);

Expand All @@ -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,
}),
}))
Expand Down

0 comments on commit ed178cb

Please sign in to comment.