Repository navigation
refactor: Cleanup user get_id/get_user_id - #20492
Conversation
There was a problem hiding this comment.
Avoiding passing around the global user. More on this in a later PR.
There was a problem hiding this comment.
The get_user_id method is a classmethod and thus doesn't return the ID associated with the user object but rather the g.user.id. In this case they're the same but it's very misleading.
There was a problem hiding this comment.
See above. This is wrong, user.get_user_id does not return user.id—for non-anonymous users—but rather g.user.id. The reason this isn't an issue is that user is always g.user. I'm working on another PR which will replace get_owner with get_user_id.
There was a problem hiding this comment.
Same logic but ensuring we use the same get_user_id method.
There was a problem hiding this comment.
Mixed types, though likely benign from the database's perspective—at least for MySQL.
There was a problem hiding this comment.
Mixed types, though likely benign from the database's perspective—at least for MySQL.
There was a problem hiding this comment.
I'm not sure what the ramifications of assigning user_id to a str was.
There was a problem hiding this comment.
Mixed types, though likely benign from the database's perspective—at least for MySQL.
There was a problem hiding this comment.
Mixed types, though likely benign from the database's perspective—at least for MySQL.
There was a problem hiding this comment.
Mixed types, though likely benign from the database's perspective—at least for MySQL.
Codecov Report
@@ Coverage Diff @@
## master #20492 +/- ##
===========================================
- Coverage 66.75% 54.98% -11.77%
===========================================
Files 1740 1745 +5
Lines 65156 65394 +238
Branches 6900 6900
===========================================
- Hits 43492 35960 -7532
- Misses 19915 27685 +7770
Partials 1749 1749
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Will we ever need to get a list of favorited charts for other users?
There was a problem hiding this comment.
@ktmud no. Also this logic is going to refactored in another PR. In general Superset does not handle users other than the current logged in user. There have been recent mechanisms added to override the user globally if needed.
fbd0f62 to
409b7d6
Compare
968ccc3 to
5fbada6
Compare
5fbada6 to
02bf074
Compare
Co-authored-by: John Bodley <[email protected]>
Co-authored-by: John Bodley <[email protected]>
SUMMARY
This is the first PR in a slew of many to cleanup/standardize the user ID/username logic. Specifically it:
Optional[str]with aget_user_idconvenience method which returnsOptional[int]. I'm not sure how problematic this was given I doubt authors know of this nuance and thus many Python==checks would have failed, i.e.,1 == "1"evaluates toFalse, however the database filters may have been more lenient, i.e., in MySQLSELECT 1 = '1'evaluates to true.get_ownerwhich returned the ID of the current user and not the referenced user.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI.
ADDITIONAL INFORMATION