-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add [CratesUserDownloads] service and tester #10619
Add [CratesUserDownloads] service and tester #10619
Conversation
part of solution for badges#10614
This commit adds the CratesUserDownloads service and tester files. The CratesUserDownloads service shows the user total downloads at Crates.io. as requested by badges#10614
🚀 Updated review app: https://pr-10619-badges-shields.fly.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Couple of minor point, but good stuff
name: 'userId', | ||
example: '3027', | ||
description: | ||
'The user ID can be found using https://crates.io/api/v1/users/{username}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This renders as a link in the docs, but following it doesn't take you anywhere useful. Can we put it in `backticks`
so it renders a <code>
block instead of a link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it looks better with code block
Made changes at 2982c8f
.get('/udt/3027.json') | ||
.expectBadge({ label: 'downloads', message: isMetric }) | ||
|
||
// we can not test for id not linked to user as it returns 0 downloads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reckon we should put in a test case for a non-existant user id anyway, .expectBadge({ label: 'downloads', message: '0' })
in the assertion and explain in a comment that this API returns {"total_downloads": 0}
with a 200 OK
instead of a 404 response for a not found user id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the test with 230c79a.
I realized they use int 32 for userid so i picked 2^32 as its the last id which has the least chance of getting taken.
userid for API usage is int32, therefor to minimize chance of user taking the id used the max value for int32 is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No further comments, let's get this merged!
This pull request adds the
CratesUserDownloads
service and tester files.The
CratesUserDownloads
service fetches data from the crates.io API to show the total downloads for a user.It also includes tests for the service.
Added
BaseCratesUserService
for api route for users.Solves #10614.