-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
Simplify Zulip Feature Level Handling. #1462
Conversation
Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out! |
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.
@rsashank Thanks for the moving the previous PR forward 👍
This certainly addresses some of the earlier points in that PR, though I did note that you dropped one change when comparing to it.
This turned out to be more work than I anticipated to complete fully, since we use various different names around the repo, including at least:
- zulip_feature_level (server field name)
- ZFL (abbreviation)
- server_feature_level (in model, to distinguish from client)
- feature_level (short variable, in tests)
That variation in names, and that they're not all code, certainly hasn't helped. Grepping through the repo, it seems there are a few outstanding unchanged parts remaining.
When you rebase and push this commit again, I suspect this will fail gitlint locally or in CI. A few other notes in that direction:
- Fixes lines are good near the bottom after a blank line
- This updates more than just the model, but you don't need to mention tests in the commit title (it's assumed they're always updated where necessary)
- Since this builds upon the other PR it would be good to add a co-authored-by field near the bottom of the commit (see
git log|grep -i co-au
for examples) - For commit text, describing what the commit changes can be good, but just as important (if not more) is the reasoning (why is integer good? why is removing None good? what did None represent? when is ZFL absent?)
@@ -278,7 +278,7 @@ def test_register_initial_desired_events(self, mocker, initial_data): | |||
None, | |||
10, | |||
{1: "Indefinite [Organization default]"}, | |||
id="ZFL=None_no_stream_retention_realm_retention=None", | |||
id="ZFL=10_no_stream_retention_realm_retention=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.
The None->10 change looks appropriate for the test case 👍
My concern here is that the text (id) here previously indicated 'ZFL=None', when it clearly is not. That may have been a typo, or indicative that we should have test case for the ZFL=0 case.
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.
Added the ZFL=0 case with the same parameters as ZFL=10.
e42a6b8
to
373b6df
Compare
"remove_18_in_home_view:already_unmuted:ZFLNone", | ||
"remove_19_in_home_view:muted:ZFLNone", | ||
"add_19_in_home_view:already_muted:ZFLNone", | ||
"add_30_in_home_view:unmuted:ZFLNone", | ||
"remove_30_is_muted:already_unmutedZFL139", | ||
"remove_18_in_home_view:already_unmuted:ZFL0", | ||
"remove_19_in_home_view:muted:ZFL0", | ||
"add_19_in_home_view:already_muted:ZFL0", | ||
"add_30_in_home_view:unmuted:ZFL0", | ||
"remove_30_is_muted:already_unmuted:ZFL139", |
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 absence of a ":" after already_unmuted seemed inconsistent with other ids. (line 3269)
While this change is unrelated to the commit/PR, it appears too minor to be a separate commit. Is that fine?
"remove_18_in_home_view:already_unmuted:ZFLNone", | ||
"remove_19_in_home_view:muted:ZFLNone", | ||
"add_19_in_home_view:already_muted:ZFLNone", | ||
"add_30_in_home_view:unmuted:ZFLNone", | ||
"remove_30_is_muted:already_unmutedZFL139", | ||
"remove_18_in_home_view:already_unmuted:ZFL0", | ||
"remove_19_in_home_view:muted:ZFL0", | ||
"add_19_in_home_view:already_muted:ZFL0", | ||
"add_30_in_home_view:unmuted:ZFL0", |
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 found these ones that weren't changed initially in the PR.
I'm still looking to identify any additional code that may need adjustments.
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.
These were others I saw previously that were missing overall 👍
Thanks for the detailed feedback! @neiljp I've updated the PR, and I believe all of them have been addressed. I couldn't find any outliers, but please correct me if I'm mistaken. (Checked using VSCode, searched for ZFL and feature_level). I'll further check with grep as well. Rebased and updated the commit message as per feedback as well. @zulipbot add "PR needs review" |
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.
Thank you @rsashank for updating the PR
I noticed that you have implemented all the suggestions given by @neiljp
As Neil mentioned in the PR feedback, we have addressed ZFL with multiple phrases like feature level, Zulip feature level, ZFL etc. in code comments or in test case IDs. How about we also add another commit to this PR which renames them to the same name? What do you think of this idea @neiljp and @rsashank ?
@mounilKshah That makes sense but what's the best way to ensure uniformity in variable names? Would simply adding |
I was referring to comments and test IDs to have a uniform naming pattern across the repository, variables need not be changed. Naming all instances as ZFL can confuse a new contributor about its meaning, so maybe we can use the entire phrase Zulip Feature Level. |
Oh my bad. Makes sense, @neiljp should I make another commit addressing this? |
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.
@rsashank Thanks for the update 👍
This looks to have full coverage for the change, so I've just pushed back with a slightly adjusted commit message.
I'd like to merge this soon (once CI passes), since tests written in other PRs assume None
is possible, so setting this new expectation would be useful!
For that reason I'd prefer to consider any followup on this refactor separately.
- While abbreviations aren't great in general, expanding ZFL would make for very long test case ids or comments (and it is very common)
- I think we could certainly expand some versions to a common form, eg. feature_level
- Documenting what ZFL corresponds to would likely be well-placed in api_types.py? We shouldn't use it in docs without the expanded form first, or point to api_types perhaps.
- We could rename ZFL/zulip_feature_level to reflect the server-provided name, ie. server_feature_level, but that would be less important in terms of making it easier to search for phrases; it may also be something we adjust if we namespace server and organization names, which has been discussed as a possible migration in the server already.
@@ -3449,7 +3456,7 @@ def test__handle_subscription_event_visual_notifications( | |||
99, | |||
[1001, 11, 12], | |||
), | |||
({"op": "peer_remove", "stream_id": 2, "user_id": 12}, None, 2, [1001, 11]), | |||
({"op": "peer_remove", "stream_id": 2, "user_id": 12}, 0, 2, [1001, 11]), |
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 believe this was one removed line from the other PR I noticed.
"remove_18_in_home_view:already_unmuted:ZFLNone", | ||
"remove_19_in_home_view:muted:ZFLNone", | ||
"add_19_in_home_view:already_muted:ZFLNone", | ||
"add_30_in_home_view:unmuted:ZFLNone", | ||
"remove_30_is_muted:already_unmutedZFL139", | ||
"remove_18_in_home_view:already_unmuted:ZFL0", | ||
"remove_19_in_home_view:muted:ZFL0", | ||
"add_19_in_home_view:already_muted:ZFL0", | ||
"add_30_in_home_view:unmuted:ZFL0", |
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.
These were others I saw previously that were missing overall 👍
When the server originally did not provide `zulip_feature_level`, this was previously represented by a `None` value in `model.server_feature_level`. This replaces the current potential `None` value with a zero value, allowing a pure integer representation in the model. This enables simplification of conditional statements when handling different server versions. The feature-level is represented by various strings in the repository, including: - server_feature_level - zulip_feature_level - ZFL - feature_level Tests updated, including test ids. Additional test case added for realm retention. Fixes zulip#1364. Co-authored-by: Lucas.C.B <[email protected]>
What does this PR do, and why?
Fixes #1364
Pure integer representation replacing the current None value when ZFL is absent.
Outstanding aspect(s)
External discussion & connections
topic
How did you test this?
Self-review checklist for each commit
Visual changes