Skip to content

Say "at least" when an API search with no total was cut to fit - #116

Merged
only-cli merged 1 commit into
only-cli:mainfrom
kevin9327:fix/api-count-without-total
Sep 28, 2026
Merged

only-cli merged 1 commit into
only-cli:mainfrom
kevin9327:fix/api-count-without-total

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

oc gem search rails says 20 gems match and gives no sign that the list goes on:

# rubygems.org search: rails
20 pages match, ranked by the site's own search:

RubyGems answers a search with a bare array of 30 per page and no total (&page=2 has 30 more). The results page keeps the first 20, and with no total field in the definition the count fell back to the 20 it shows, so the "top 20 shown" note never appeared.

After:

# rubygems.org search: rails
at least 30 pages match, ranked by the site's own search, top 20 shown:

With no total, the count is now how many results the answer carried, and when that is more than the page shows it is stated as a floor. A list that fits is counted exactly as before ("5 pages match"), and the sites that report a total (npm, crates.io, MDN) render the same.

Test. tests/apisearch.test.js gains one test with a RubyGems-shaped answer: 30 results give "at least 30 pages match, ..., top 20 shown:", and 5 results give "5 pages match, ranked by the site's own search:". On main the first assertion fails (it reads "20 pages match"). Full suite: 311 tests, 308 pass, 3 skipped, 0 fail.

Left alone. oc still fetches one page of results; paging the API is a different change.

🤖 Generated with Claude Code

'oc gem search rails' answered "20 pages match, ranked by the site's own
search:". RubyGems answers a search with a bare array of 30 and no total,
the page keeps the first 20, and with no total the count fell back to the
20 shown, so nothing said the list went on or that a second page exists.

With no total, the count is now how many results the answer carried, and
when that is more than the page shows it reads as a floor: "at least 30
pages match, ranked by the site's own search, top 20 shown:". A list
that fits is counted as before, and a site that reports its total (npm,
crates.io, MDN) is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@only-cli
only-cli merged commit 1680245 into only-cli:main Sep 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants