Skip to content

Commit

Permalink
chore: improve /v1/publication/list_by_gids api.
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Sep 20, 2023
1 parent f22e672 commit 43564bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "writing"
version = "1.0.1"
version = "1.0.2"
edition = "2021"
rust-version = "1.64"
description = ""
Expand Down
6 changes: 4 additions & 2 deletions src/db/model_publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ impl Publication {
};

let mut i = 0i8;
while i < 14 {
while i < 7 {
let raw = end_id.as_bytes();
let unix_ts = u32::from_be_bytes([raw[0], raw[1], raw[2], raw[3]]);
let mut start_id = xid::Id::default();
Expand Down Expand Up @@ -810,7 +810,9 @@ impl Publication {
}
}

if !res.is_empty() {
// result should >= 6 for first page.
if (page_token.is_none() && res.len() >= 6) || (page_token.is_some() && res.len() >= 3)
{
res.sort_by(|a, b| b.cid.partial_cmp(&a.cid).unwrap());
return Ok((res, Some(start_id)));
}
Expand Down

0 comments on commit 43564bc

Please sign in to comment.