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

New generator request: Faker::Commerce.rating #2809

Closed
bradly opened this issue Aug 11, 2023 · 2 comments
Closed

New generator request: Faker::Commerce.rating #2809

bradly opened this issue Aug 11, 2023 · 2 comments

Comments

@bradly
Copy link

bradly commented Aug 11, 2023

Is your feature request related to a problem? Please describe it.
I had a need for product ratings/number of stars. A rating by by default is float with one decimal between 0 and 5. I.e. 3.6

For example, if proposing a new generator, explain why it's useful and relevant to Faker, and examples of how to use it in a real project.

Describe alternatives you've considered
I considered using Faker::Number.decimal, but I can't limit the range to 0-5, only the number of digits on each side of the decimal.

I've also considered creating this outside of Commerce so it can be used for a Book, App, Restaurant, etc., but decided to kept it as simple as possible.

Additional context
Since the return value is numeric, no translations are needed.

Updated docs
image

@bradly
Copy link
Author

bradly commented Aug 11, 2023

I didn't see the checkbox to open an issue before writing any code, so I did things a bit out of order here and already opened a pr in #2808. Sorry about that.

@stefannibrasil
Copy link
Contributor

No worries, thanks for the screenshot, that's neat! I left some comments in the PR.

I don't have lots of background with product ratings but you mention here that the default is a decimal. I've mostly seen integers, though. Mainly because I use the 5 start reviews when I rate something :P Would it be helpful to allow decimals but have an integer as the default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants