Skip to content
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

refactor(QueryContext): add QueryContextFactory to meet SRP #17495

Merged

Conversation

ofekisr
Copy link
Contributor

@ofekisr ofekisr commented Nov 21, 2021

Background

When we have worked on #16991 we wanted to test the new functionalities in concrete and accurate unittest.
All chartData flows and its components are too couple to superset so it is impossible to create unittests.
The flows are not testable and so many components do not meet the very important principle SRP and the code became so dirty

So I've started to refactor it (#17344 ) but many changes were added and it was hard to review so I decided to split those changes into small PRs so will be easier to follow

This is the tenth PR in a sequence of PRs to meet these
The next PR is #17496

PR description

Creating QueryContext is not only an assignment task, it contains some logic.
To meet the SRP, The creation task should be assigned to an external object.
After the PR the QueryContext constructor is decoupled from Superset so in the next PRs, the module can be decoupled from Superset

Test plans

There is no logic added so new tests are not required

Previous PRs

  1. refactor(ChartData): move ChartDataResult enums to common #17399
  2. refactor(ChartData): move chart_data_apis from ChartRestApi ChartDataRestApi #17400
  3. refactor(ChartDataCommand): separate loading query_context form cache into different module #17405
  4. refactor(TestChartApi): move chart data api tests into TestChartDataApi #17407
  5. refactor(ChartDataCommand): into two separate commands #17425
  6. refactor(ChartDataCommand): remove create queryContext command's responsibly  #17461
  7. refactor(QueryObject): decouple from queryContext and clean code #17465
  8. refactor(QueryObject): add QueryObjectFactory to meet SRP #17466
  9. refactor(QueryObject): decouple from superset #17479

Copy link
Member

@amitmiran137 amitmiran137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Nov 21, 2021

Codecov Report

Merging #17495 (3c5c32a) into master (261e418) will decrease coverage by 0.07%.
The diff coverage is 79.48%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #17495      +/-   ##
==========================================
- Coverage   76.97%   76.90%   -0.08%     
==========================================
  Files        1043     1044       +1     
  Lines       56381    56435      +54     
  Branches     7798     7798              
==========================================
- Hits        43402    43399       -3     
- Misses      12723    12780      +57     
  Partials      256      256              
Flag Coverage Δ
hive 81.55% <79.48%> (-0.02%) ⬇️
mysql 81.97% <79.48%> (-0.02%) ⬇️
postgres 81.98% <79.48%> (-0.02%) ⬇️
presto ?
python 82.33% <79.48%> (-0.17%) ⬇️
sqlite 81.66% <79.48%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/viz.py 58.05% <33.33%> (-0.07%) ⬇️
superset/views/api.py 67.18% <50.00%> (-4.25%) ⬇️
superset/common/query_context.py 91.40% <87.50%> (-0.60%) ⬇️
superset/models/slice.py 85.07% <90.00%> (+0.02%) ⬆️
superset/charts/schemas.py 99.65% <90.90%> (-0.35%) ⬇️
superset/common/query_context_factory.py 96.42% <96.42%> (ø)
superset/db_engine_specs/presto.py 84.30% <0.00%> (-6.07%) ⬇️
superset/connectors/sqla/models.py 87.02% <0.00%> (-1.36%) ⬇️
superset/models/core.py 89.26% <0.00%> (-0.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 261e418...3c5c32a. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 1.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants