-
Notifications
You must be signed in to change notification settings - Fork 0
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
Don’t return story translations if user already translating/reviewing for language #229
Conversation
@@ -51,3 +59,10 @@ def resolve_story_translation_tests(root, info, language, level, stage, story_ti | |||
return services["story"].get_story_translation_tests( | |||
user, language, level, stage, story_title | |||
) | |||
|
|||
|
|||
def _select_user_id_for_available_translations_query(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.
Putting this here because moving it to story_service means adding the user service to the story service. Also, this sticks to the principle of keeping authentication out of the story services. lmk if you can think of a better name tho LOL
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.
what do you think about something like target_user_id
instead of searching_user_id
? i'm not sure if it's more readable or not
and consequently something like _target_user_id_for_available_translations_query
for the helper
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 think the verb "select" makes more sense than "target" for the function name, but I will swap searching_user_id for target_user_id !
@@ -173,7 +165,9 @@ def create_translation_test(self, user_id, level, language): | |||
raise error | |||
return new_story_translation | |||
|
|||
def get_story_translations_by_user(self, user_id, is_translator, language, level): | |||
def get_story_translations_by_user( | |||
self, user_id, is_translator=None, language=None, level=None |
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.
made this change to make the function header more readable
Visit the preview URL for this PR (updated for commit 4d1d49a): https://planet-read-uwbp--pr229-fix-dont-return-tran-lhgz5wmi.web.app (expires Fri, 31 Dec 2021 04:36:26 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
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.
LGTM!
@@ -51,3 +59,10 @@ def resolve_story_translation_tests(root, info, language, level, stage, story_ti | |||
return services["story"].get_story_translation_tests( | |||
user, language, level, stage, story_title | |||
) | |||
|
|||
|
|||
def _select_user_id_for_available_translations_query(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.
what do you think about something like target_user_id
instead of searching_user_id
? i'm not sure if it's more readable or not
and consequently something like _target_user_id_for_available_translations_query
for the helper
|
||
stories = ( | ||
Story.query.filter(Story.level == level) | ||
.filter(~Story.translated_languages.contains(language)) |
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.
just a q: what does the ~Story...
syntax mean?
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.
negation! this reads as return story translations where translated_languages does not contain language
a108f5f
to
4d1d49a
Compare
Notion ticket link
https://www.notion.so/uwblueprintexecs/a658c933d18c48d4b43fd99bda2bd3b4?v=ba22ac93d09040ff8219c60ac7caabdb&p=fc6fd704b0674be19c756b4a1c30ef6c)
Implementation description
_get_story_translations_user_translating
and_get_story_translations_user_reviewing
for flexible query builderget_stories_available_for_translation
andget_story_translations_available_for_review
Steps to test
Homepage View
Translate
create_translation
!)Review
assign_user_as_reviewer
!)Admin UserProfile View
erase & reseed db
Translate
Review
What should reviewers focus on?
Checklist
docker exec -it planet-read_py-backend_1 /bin/bash -c "black . && isort --profile black ."
and I have generated new migrations:flask db migrate -m "<your message>"