Repository navigation
Show versions held back by cooldown on the package page and in the API - #639
Conversation
Part of git-pkgs#617. The package page marks versions in cooldown with when they become available, and lists a version only seen in metadata (no artifact row) only while it is held back. /api/package returns the package's cooldown and available_at on a held-back version. FillVersionPublishedAt stores a publish time without overwriting one, for the cooldown filters to call once they record the versions they hold back.
|
Leaving this in draft for now to keep the review queue short. It can wait until you want it, or I'll close it if it doesn't fit. |
andrew
left a comment
There was a problem hiding this comment.
Thanks, the package page side reads well, and listing metadata-only versions only while they're held back is what I was after. It's useful before #533 lands too, since the download checks already write publish times for npm, pypi, composer, go and maven.
available_at on /api/package/{ecosystem}/{name}/{version} isn't tested. TestAPIPackageCooldown calls packageCooldown directly, and nothing goes through getVersion. Please add a test through HandlePackagePath with a stubbed http.DefaultTransport, like swift_vulns_test.go does, checking that a recently published version gets cooldown and available_at in the JSON and an old one has no available_at.
FillVersionPublishedAt has no caller outside its tests yet, and its comment says the cooldown filters call it, which isn't true on this branch. I'd drop it and its tests from this PR and add them with the shared filter helper once #533 is in, so it lands with its caller.
Two comments in api.go restate the code and can go: the one on newAPIHandler and the one on apiTimeFormat.
The API handler takes the enrichment calls it uses as an interface, so the test can answer them without reaching a registry. Remove FillVersionPublishedAt until the shared cooldown filter calls it.
|
Done in 683455a:
|
Part of #617, items 3 and 4. Draft because the filter sites wait for #533, as asked there.
FillVersionPublishedAtstores a version's publish time without overwriting one already stored (DO UPDATE ... WHERE versions.published_at IS NULL), so the filters can call it without a read first./api/package/{ecosystem}/{name}returnscooldownin the configuration's syntax ("3d","0"for an exempted package), and the version response hasavailable_aton a held-back version. Bothomitempty, timestamps formatted likepublished_at.One difference from your answer: a version counts as fetched when it has any artifact row, also one evicted since, so evicting a release doesn't drop it from the list.
Still to do once #533 merges: the shared helper the cooldown filters call for each version they hold back, and the calls at the filter sites. The helper also needs to create the package row, or the page of a package nobody downloaded is a 404.
Tested with the DB tests on SQLite and Postgres and a request through
/ui/package/npm/lodashwith fetched, held-back and expired versions.