Skip to content

Commit 41ebf28

Browse files
committed
fix to include --until value in gh search query so since/until params respected
1 parent aacbd17 commit 41ebf28

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

  • packages/gen-ai/.claude/skills/flake-check/scripts

packages/gen-ai/.claude/skills/flake-check/scripts/scan_prs.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,27 @@ def main() -> None:
307307
"--json", "number,title,author,createdAt,state,headRefOid",
308308
]
309309

310+
search_parts = []
310311
if args.since:
311-
gh_args += ["--search", f"created:>={args.since.isoformat()}"]
312+
search_parts.append(f"created:>={args.since.isoformat()}")
313+
if args.until:
314+
# Include in the search query so the API scopes results to the window,
315+
# preventing newer PRs from consuming the result budget before we reach
316+
# the target window (the search API sorts by recency of update by default).
317+
search_parts.append(f"created:<{args.until.isoformat()}")
318+
if search_parts:
319+
gh_args += ["--search", " ".join(search_parts)]
312320

313321
raw = run_gh(*gh_args)
314322
prs_raw: list[dict] = json.loads(raw)
315323

316-
# Client-side --until filter
324+
# limit_hit must be checked on the raw pre-filter list; filtering below reduces
325+
# the count so checking after would produce a false negative.
326+
limit_hit = len(prs_raw) > effective_limit
327+
prs_raw = prs_raw[:effective_limit]
328+
329+
# Client-side --until filter as a safety net (search query already scopes this,
330+
# but keep the guard in case gh CLI doesn't forward the query correctly).
317331
if args.until:
318332
until_iso = args.until.isoformat()
319333
prs_raw = [p for p in prs_raw if p["createdAt"][:10] < until_iso]
@@ -329,10 +343,6 @@ def main() -> None:
329343
filtered.append(pr)
330344
prs_raw = filtered
331345

332-
# If we got more than the limit, there are additional PRs beyond this window
333-
limit_hit = len(prs_raw) > effective_limit
334-
prs_raw = prs_raw[:effective_limit]
335-
336346
pr_results: list[dict] = []
337347
all_passing_count = 0
338348
# check_name -> PR numbers where it was the latest failing conclusion

0 commit comments

Comments
 (0)