Skip to content
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 [GitLab] Top Language Badge #10750

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

KoruptTinker
Copy link
Contributor

No description provided.

Copy link
Contributor

github-actions bot commented Dec 17, 2024

Messages
📖 ✨ Thanks for your contribution to Shields, @KoruptTinker!

Generated by 🚫 dangerJS against 4d082d7

@KoruptTinker
Copy link
Contributor Author

Closes #10181

@KoruptTinker
Copy link
Contributor Author

Pending: Test cases

@KoruptTinker
Copy link
Contributor Author

Need help handling case where the API returns an empty object. Happens when the repository has no code. Only markdown?
Any suggestions ?

@chris48s chris48s added the service-badge New or updated service badge label Dec 17, 2024
@chris48s
Copy link
Member

chris48s commented Dec 17, 2024

I'll hold off on a proper review until you've got some tests. You've said:

Need help handling case where the API returns an empty object. Happens when the repository has no code. Only markdown?
Any suggestions ?

Broadly there are two patterns we can use here:

One is to write the Joi schema such that this response is rejected and just accept that this case will throw the generic validation error message.

The other pattern is you can write the schema such that this response is allowed and throw an InvalidResponse exception if the object is empty. That allows you to customise the message, but we might need to also implement a bit of additional validation if we can't totally rely on the schema.

If you're still struggling, can you post an example of a repo or API call that has the problem you're trying to handle.

@KoruptTinker
Copy link
Contributor Author

Test cases added.
Ready for a review @chris48s

@KoruptTinker
Copy link
Contributor Author

can you post an example of a repo or API call that has the problem you're trying to handle.

https://gitlab.com/api/v4/projects/KoruptTinker%2Fgitlab-blank-repo/languages

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Couple of comments. Aside from those, this is in good shape.

Comment on lines 55 to 61
} else {
return {
label: 'no languages found',
message: 'NA',
color: 'blue',
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we

throw new InvalidResponse({ prettyMessage: 'no languages found' })

here and update the test.

Comment on lines 7 to 9
const schema = Joi.object()
.pattern(Joi.string(), Joi.number().min(0).max(100).precision(2))
.required()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object key and value should both be .required(), so

Suggested change
const schema = Joi.object()
.pattern(Joi.string(), Joi.number().min(0).max(100).precision(2))
.required()
const schema = Joi.object()
.pattern(
Joi.string().required(),
Joi.number().min(0).max(100).precision(2).required(),
)
.required()

here

@KoruptTinker
Copy link
Contributor Author

Requested changes made.

Copy link
Contributor

🚀 Updated review app: https://pr-10750-badges-shields.fly.dev

Copy link
Member

@chris48s chris48s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thanks 👍

@chris48s chris48s added this pull request to the merge queue Dec 20, 2024
Merged via the queue into badges:master with commit f643515 Dec 20, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge New or updated service badge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants