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
Conversation
critiquebrainz/db/avg_rating.py
Outdated
|
||
return dict(avg_rating) | ||
return (avg_rating) |
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.
Parentheses around a return value are unnecessary.
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.
Removed
critiquebrainz/db/review.py
Outdated
@@ -19,6 +19,7 @@ | |||
"place", | |||
"release_group", | |||
] | |||
RATING_SCALE_1_5 = {20: 1, 40: 2, 60: 3, 80: 4, 100: 5} |
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.
Since there is a module specifically related to ratings it might be better to put these values there instead.
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.
Sorry, didn't get you. Which module are you talking about?
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 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.
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.
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.
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.
Sure, not ideal but better.
critiquebrainz/db/revision.py
Outdated
@@ -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} |
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.
Again, these also belong in the rating module.
1d10a13
to
98efa3b
Compare
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.