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

Checkout plugins rework #4980

Merged
merged 17 commits into from
Nov 26, 2019
Merged

Checkout plugins rework #4980

merged 17 commits into from
Nov 26, 2019

Conversation

krzysztofwolski
Copy link
Member

@krzysztofwolski krzysztofwolski commented Nov 15, 2019

I want to merge this change because...

Screenshots

Pull Request Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. Database migration files are up to date.
  6. The changes are tested.
  7. GraphQL schema and type definitions are up to date.
  8. Changes are mentioned in the changelog.

checkout: "Checkout", discounts: "DiscountsListType" = None
) -> TaxedMoney:
"""Return checkout shipping price."""
# FIXME: should it take discounts in account?
Copy link
Member Author

Choose a reason for hiding this comment

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

@korycins wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any usage of discount for shipping, so I assume that we can skip them for base but plugin should still recieve a discounts for calculate_checkout_shipping

@krzysztofwolski
Copy link
Member Author

There are conflicts to be fixed - but I would like to hear what do you think bout those changes

saleor/checkout/base_calculations.py Show resolved Hide resolved
saleor/checkout/models.py Outdated Show resolved Hide resolved
saleor/core/taxes.py Show resolved Hide resolved
saleor/discount/utils.py Outdated Show resolved Hide resolved
saleor/checkout/base_calculations.py Show resolved Hide resolved
checkout: "Checkout", discounts: "DiscountsListType" = None
) -> TaxedMoney:
"""Return checkout shipping price."""
# FIXME: should it take discounts in account?
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any usage of discount for shipping, so I assume that we can skip them for base but plugin should still recieve a discounts for calculate_checkout_shipping

saleor/checkout/base_calculations.py Outdated Show resolved Hide resolved
saleor/checkout/calculations.py Outdated Show resolved Hide resolved
CENTS = Decimal("0.01")
if TYPE_CHECKING:
from ..product.models import ProductVariant
from django_measurement import Weight
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if isort handled that. Maybe we could separate 3rd packages from our modules? Or just put it above the if

Copy link
Member

Choose a reason for hiding this comment

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

Related issue: PyCQA/isort#818

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe laziness is speaking thru me, but unless any tool does not manage that, I don't want to go back to pre isort/black time and deal with it manually :/ Type checking sections tend to be way smaller than usual imports so maybe it's not an issue?

saleor/checkout/utils.py Outdated Show resolved Hide resolved
saleor/checkout/utils.py Show resolved Hide resolved
saleor/checkout/utils.py Show resolved Hide resolved
saleor/discount/utils.py Outdated Show resolved Hide resolved
saleor/extensions/plugins/avatax/plugin.py Outdated Show resolved Hide resolved
@krzysztofwolski
Copy link
Member Author

I don't understand codeclimate. According to http://pylint.pycqa.org/en/latest/whatsnew/2.0.html TYPE_CHECKING should be handled by pylint :/

Copy link

django-queries commented Nov 21, 2019

Here is the report for 08efd3a (krzysztofwolski/saleor @ checkout-plugins-rework)
Base comparison is 67cce44.

No differences were found. (click me)

# api.benchmark checkout
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  add billing address to checkout            	         34	         34	             20
  add shipping to checkout                   	          7	          7	              0
  checkout payment charge                    	         10	         10	              0
  complete checkout                          	          8	          8	              0
  create checkout                            	         50	         50	             24

# api.benchmark homepage
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  retrieve main menu                         	          5	          5	              0
  retrieve product list                      	          4	          4	              0
  retrieve secondary menu                    	          5	          5	              0
  retrieve shop                              	          2	          2	              0

# api.benchmark product
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  product details                            	         15	         15	              3
  retrieve product attributes                	          9	          9	              0

# api.benchmark variant
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  product variant bulk create                	         51	         51	              3
  retrieve variant list                      	         15	         15	              6

# api product sorting attributes
  test name                                  	left count 	right count	duplicate count
  -------------------------------------------	-----------	-----------	---------------
  sort product not having attribute data     	         21	         21	              0

@codecov
Copy link

codecov bot commented Nov 21, 2019

Codecov Report

Merging #4980 into master will decrease coverage by 0.2%.
The diff coverage is 73.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4980      +/-   ##
==========================================
- Coverage   91.21%   91.01%   -0.21%     
==========================================
  Files         351      353       +2     
  Lines       21404    21434      +30     
  Branches     2044     2050       +6     
==========================================
- Hits        19524    19508      -16     
- Misses       1326     1371      +45     
- Partials      554      555       +1
Impacted Files Coverage Δ
saleor/extensions/base_plugin.py 88.88% <0%> (-0.72%) ⬇️
saleor/extensions/plugins/vatlayer/plugin.py 70.17% <100%> (-1.96%) ⬇️
saleor/core/taxes.py 94.44% <100%> (-0.3%) ⬇️
saleor/graphql/product/types/products.py 91.2% <100%> (ø) ⬆️
saleor/extensions/plugins/avatax/plugin.py 59.57% <21.42%> (-9.79%) ⬇️
saleor/extensions/plugins/avatax/__init__.py 80.09% <40%> (+2.21%) ⬆️
saleor/seo/schema/email.py 87.87% <60%> (-5.46%) ⬇️
saleor/checkout/models.py 94.62% <66.66%> (-4.39%) ⬇️
saleor/extensions/manager.py 89.8% <66.66%> (-0.58%) ⬇️
saleor/payment/gateway.py 94.11% <66.66%> (-1.41%) ⬇️
... and 10 more

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 67cce44...08efd3a. Read the comment docs.

saleor/checkout/base_calculations.py Outdated Show resolved Hide resolved
saleor/checkout/calculations.py Outdated Show resolved Hide resolved
saleor/extensions/plugins/avatax/plugin.py Outdated Show resolved Hide resolved
saleor/extensions/plugins/avatax/plugin.py Outdated Show resolved Hide resolved
saleor/extensions/plugins/vatlayer/plugin.py Show resolved Hide resolved
saleor/checkout/utils.py Outdated Show resolved Hide resolved
saleor/checkout/utils.py Outdated Show resolved Hide resolved
saleor/discount/utils.py Show resolved Hide resolved
saleor/checkout/utils.py Outdated Show resolved Hide resolved
@krzysztofwolski krzysztofwolski merged commit 7a4dbe2 into saleor:master Nov 26, 2019
@krzysztofwolski krzysztofwolski deleted the checkout-plugins-rework branch November 26, 2019 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shipping calculation, totals and plugins
7 participants