-
Notifications
You must be signed in to change notification settings - Fork 12
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
Adds filtering by post author's native languages to post list (#140) #421
Open
alexcjwei
wants to merge
4
commits into
LangCorrect:main
Choose a base branch
from
alexcjwei:140-filter-by-author-native-language
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e5f7aca
Adds filtering by post author's native languages to post list (#140)
alexcjwei 4510e7c
fixes counts of post author native language filter (#140)
alexcjwei 1692e5d
fixes select logic for post list language filters
alexcjwei 37c4ad3
fixes pagination bug from filtering
alexcjwei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Recording.2024-01-18.150627.mp4
We have a couple of issues:
Posts do not filter correctly when lang_code is
None
See video.
http://127.0.0.1:8000/journals/?mode=teach&author_native_lang_code=ja&lang_code=None
What's happening here is that language code will evaluate to the string
"None"
which is a truthy value. So, we will either need to update the conditionals or explicitly check for this and returnNone
:I would also look into your
get_author_native_lang_code
method.Incorrect post counts when both the native language and language codes are selected
See video. The count is displayed is
12
, but the actual count is14
.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.
The issue comes from how we're setting the query params from the frontend. In
get_context_data
, we return the result of these getters, which in Python areNone
. These get passed back asselected_lang_code
, which we use to create the url inpost_list.html
, and end up making the url look like?mode=teach&author_native_lang_code=all&lang_code=None
If we modify the getters to just default to the value "all", then we won't receive "None" in the query params.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.
Need to look into incorrect post counts, should look for discrepancy btwn
posts/views.py
andposts/helpers.py
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.
Also, right now the native language counts are a subset of the original language code (i.e it should always be less than or equal to the count of the original language code). This make it a little confusing if you try to set the original language code after first setting the native language code. Not sure what the best solution is -- maybe for consistency, the count should always reflect the posts that would be shown as a result of applying that filter? In which case we'd have to update the original one to take into account the native language filter. Do you agree?
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.
From my observations, the native speaking language filter seems to always be off by one (lower)
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 like your solution 💯
Good point -- let's make it consistent. I'm not sure where else that function is currently being used, so we would need to make sure it doesn't break elsewhere.