Skip to content

Commit

Permalink
add desc sort by batch id (block number)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill-K-1 committed Nov 18, 2024
1 parent c0f2f8b commit 4b75941
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
12 changes: 6 additions & 6 deletions gov-portal-db/src/rewards_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ impl RewardsManager {

let find_options = FindOptions::builder()
.max_time(self.db_client.req_timeout)
// .sort(doc! {
// "timestamp": -1
// })
.sort(doc! {
"id": -1,
})
.skip(start)
.limit(limit)
.build();
Expand Down Expand Up @@ -389,9 +389,9 @@ impl RewardsManager {

let find_options = FindOptions::builder()
.max_time(self.db_client.req_timeout)
// .sort(doc! {
// "timestamp": -1
// })
.sort(doc! {
"id": -1,
})
.skip(start)
.limit(limit)
.projection(doc! {
Expand Down
14 changes: 6 additions & 8 deletions gov-portal-db/tests/test_rewards_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn test_rewards_endpoint() -> Result<(), anyhow::Error> {

assert_matches!(
rewards_manager
.get_rewards(&Address::from_low_u64_le(0), None, None, None, None, None)
.get_rewards(&Address::from_low_u64_le(0), None, None, None, None, None,)
.await,
Err(error::Error::Unauthorized)
);
Expand All @@ -165,7 +165,7 @@ async fn test_rewards_endpoint() -> Result<(), anyhow::Error> {
None,
None,
None,
None
None,
)
.await,
Err(error::Error::Unauthorized)
Expand All @@ -187,7 +187,7 @@ async fn test_rewards_endpoint() -> Result<(), anyhow::Error> {
None,
None,
None,
None
None,
)
.await
.is_ok());
Expand All @@ -200,7 +200,7 @@ async fn test_rewards_endpoint() -> Result<(), anyhow::Error> {
Some(0),
None,
None,
None
None,
)
.await
.unwrap()
Expand Down Expand Up @@ -378,7 +378,7 @@ async fn test_rewards_by_wallet() -> Result<(), anyhow::Error> {
let mut all_rewards = Vec::with_capacity(1000);

loop {
let Ok(batch) = rewards_manager
let batch = rewards_manager
.get_rewards(
&addr_grantor,
Some(all_rewards.len() as u64),
Expand All @@ -388,9 +388,7 @@ async fn test_rewards_by_wallet() -> Result<(), anyhow::Error> {
None,
)
.await
else {
panic!("Failed to fetch rewards")
};
.unwrap();

if batch.is_empty() {
break;
Expand Down

0 comments on commit 4b75941

Please sign in to comment.