refactor(explore): extract session ID retrieval into overridable method - #35779
Conversation
Code Review Agent Run #f1f39cActionable Suggestions - 0Additional Suggestions - 6
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
There was a problem hiding this comment.
I've completed my review and didn't find any issues.
Files scanned
| File Path | Reviewed |
|---|---|
| superset/commands/explore/form_data/create.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
Interaction Diagram by BitosequenceDiagram
participant API as ExploreFormDataRestApi<br/>🔄 Updated | ●●○ Medium
participant CMD as CreateFormDataCommand<br/>🔄 Updated | ●●○ Medium
participant SES as Flask Session
participant ACC as Access Control
participant CACHE as Cache Manager
participant KEY as Cache Key Utils<br/>🔄 Updated | ●●○ Medium
Note over CMD: Added _get_session_id()<br/>method for testability
API->>CMD: CreateFormDataCommand(params).run()
CMD->>CMD: _get_session_id()
CMD->>SES: session.get("_id")
SES-->>CMD: session_id
CMD->>ACC: check_access(datasource_id, chart_id, type)
ACC-->>CMD: access_granted
CMD->>KEY: cache_key(session_id, tab_id, datasource_id, chart_id, type)
KEY-->>CMD: contextual_key
CMD->>CACHE: explore_form_data_cache.get/set
CACHE-->>API: form_data_key
Critical path: ExploreFormDataRestApi->CreateFormDataCommand->Flask Session->Cache Key Utils->Cache Manager
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #35779 +/- ##
===========================================
+ Coverage 0 71.03% +71.03%
===========================================
Files 0 605 +605
Lines 0 44209 +44209
Branches 0 4782 +4782
===========================================
+ Hits 0 31406 +31406
- Misses 0 11558 +11558
- Partials 0 1245 +1245
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| def __init__(self, cmd_params: CommandParameters): | ||
| self._cmd_params = cmd_params | ||
|
|
||
| def _get_session_id(self) -> str: |
There was a problem hiding this comment.
can't this function also return None? as session.get("_id") could not exist, right?
| from superset.utils.core import DatasourceType | ||
|
|
||
|
|
||
| def test_get_session_id_returns_session_id(): |
There was a problem hiding this comment.
Do we still need this test if test_run_uses_get_session_id already calls _get_session_id?
There was a problem hiding this comment.
you are right i will get rid of it
- Extract session.get('_id') into _get_session_id() method in CreateFormDataCommand
- Allow subclasses to override session ID retrieval for custom behavior
- Add comprehensive unit tests for the new method
b2ea463 to
86bf532
Compare
…od (apache#35779) (cherry picked from commit 6f50ddf)
…od (apache#35779) (cherry picked from commit 6f50ddf)
SUMMARY
This PR extracts the session ID retrieval logic in
CreateFormDataCommandinto a separate_get_session_id()method that can be overridden in subclasses. This improves testability and allows for custom session ID handling in derived classes.Changes:
session.get('_id')into_get_session_id()method inCreateFormDataCommandrun()method to useself._get_session_id()instead of directly accessing sessionBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend refactoring with no UI changes
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION