hive-forge: warn when --tail saturates the pagination cap (argus 🟡 on #770)
This commit is contained in:
parent
5f4494c239
commit
7d31b7def4
1 changed files with 17 additions and 0 deletions
|
|
@ -92,12 +92,29 @@ fn fetch_head(client: &Client, repo: &str, number: u64, limit: u64) -> Result<Ve
|
|||
/// items in chronological order. Forgejo orders
|
||||
/// `/issues/<n>/comments` oldest-first so the trailing slice maps
|
||||
/// directly to "most recent N".
|
||||
///
|
||||
/// When the fetch saturates `TAIL_MAX_PAGES` (i.e. all 20 pages came
|
||||
/// back full at 50/page) we can't tell whether more comments exist
|
||||
/// upstream. Surface a stderr warning so the caller knows the
|
||||
/// "tail" is anchored to the first 1000 comments, not necessarily
|
||||
/// the actual newest of the thread. False positive: a thread with
|
||||
/// EXACTLY 1000 comments will warn even though the slice IS the
|
||||
/// real tail — acceptable noise given how rare 1000-comment threads
|
||||
/// are (closes argus 🟡 on PR #770).
|
||||
fn fetch_tail(client: &Client, repo: &str, number: u64, n: usize) -> Result<Vec<Value>> {
|
||||
let all = client.get_json_all(
|
||||
&format!("/repos/{repo}/issues/{number}/comments?limit=50"),
|
||||
TAIL_MAX_PAGES,
|
||||
)?;
|
||||
let total = all.len();
|
||||
if total >= TAIL_MAX_PAGES as usize * 50 {
|
||||
eprintln!(
|
||||
"warning: hit pagination cap ({TAIL_MAX_PAGES} pages × 50 = \
|
||||
{total} comments); --tail slice is anchored to the first \
|
||||
{total} comments and may not include the actual newest of \
|
||||
the thread."
|
||||
);
|
||||
}
|
||||
if total <= n {
|
||||
return Ok(all);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue