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

Constrain rating storage conversions within one module #152

Merged
merged 6 commits into from Sep 3, 2017

Conversation

breakbuidl
Copy link
Contributor

Now, the whole CB codebase can use the scale of 1-5 for ratings.
For storage, ratings will be converted to the scale 0-100 right before inserting them into the database.


return dict(avg_rating)
return (avg_rating)
Copy link
Contributor

Choose a reason for hiding this comment

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

Parentheses around a return value are unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@@ -19,6 +19,7 @@
"place",
"release_group",
]
RATING_SCALE_1_5 = {20: 1, 40: 2, 60: 3, 80: 4, 100: 5}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there is a module specifically related to ratings it might be better to put these values there instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, didn't get you. Which module are you talking about?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess there's no rating module there, but https://github.com/metabrainz/critiquebrainz/blob/master/critiquebrainz/db/avg_rating.py is probably the closes. In any case, a more relevant place to have these definitions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will __init__.py be a good place for this? I know avg_rating.py is related to ratings but it doesn't seem a good fit for rating conversion scales.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, not ideal but better.

@@ -5,6 +5,10 @@
from critiquebrainz.db import exceptions as db_exceptions
import sqlalchemy

VALID_RATING_VALUES = [None, 1, 2, 3, 4, 5]
RATING_SCALE_0_100 = {1: 20, 2: 40, 3: 60, 4: 80, 5: 100}
RATING_SCALE_1_5 = {20: 1, 40: 2, 60: 3, 80: 4, 100: 5}
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, these also belong in the rating module.

@gentlecat gentlecat changed the title Convert rating values to appropriate scales before inserting into database and after retrieving from database Constrain rating storage conversions within one module Aug 31, 2017
@gentlecat gentlecat merged commit d462984 into metabrainz:master Sep 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants