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
Concept of the shopping lists' line item update actions. #614
Conversation
Codecov Report
@@ Coverage Diff @@
## shopping-lists-base-branch #614 +/- ##
=============================================================
Coverage 99.35% 99.35%
Complexity 2424 2424
=============================================================
Files 194 194
Lines 6084 6084
Branches 377 377
=============================================================
Hits 6045 6045
Misses 20 20
Partials 19 19 Continue to review full report at Codecov.
|
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
…actions.md Co-authored-by: King-Hin Leung <35692276+leungkinghin@users.noreply.github.com>
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
<!-- What becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated. --> | ||
|
||
- To ensure the order, we need to remove and add line items, which means a bigger payload, so performance overhead. | ||
- [Add TextLineItem](https://docs.commercetools.com/api/projects/shoppingLists#add-textlineitem) is not checking the data is exists, so a user could add the |
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.
- [Add TextLineItem](https://docs.commercetools.com/api/projects/shoppingLists#add-textlineitem) is not checking the data is exists, so a user could add the | |
- [Add TextLineItem](https://docs.commercetools.com/api/projects/shoppingLists#add-textlineitem) is not checking if the data exists. A user could add the |
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 don't understand well this consequence. Can you explain?
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.
What kind of explanation? Update action JSON?
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
"addedAt": "2020-11-04T09:38:35.571Z" | ||
}, | ||
{ | ||
"id": "24de3821-e27d-4ddb-bd0b-ecc99365285f", |
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.
Is it supposed to have different ID as LineItem SKU-1?
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.
<p> So we need to create an <a href="https://docs.commercetools.com/api/projects/shoppingLists#add-lineitem">AddLineItem</a> action | ||
, a <a href="https://docs.commercetools.com/api/projects/shoppingLists#remove-lineitem">RemoveLineItem</a> action and | ||
a <a href="https://docs.commercetools.com/api/projects/shoppingLists#change-lineitems-order">Change LineItems Order</a> | ||
of the line items <b>SKU-1</b> and <b>SKU-3</b>, because when we add line item with <b>SKU-1</b> |
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 don't understand here.
In the drafts, the order is ['sku-1', 'sku-3']. Isn't it expected and no need to change the order?
I would understand ChangeLineitemOrder
is required if the order in drafts is ['sku-3', 'sku-1']
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.
Looks like same, #614 (comment)
"lineItems": [ | ||
{ | ||
"sku": "SKU-1", | ||
"quantity": 1, |
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.
Is quantity supposed to update? I see the quantity of existing lineitem 'sku-1' is different.
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.
{ | ||
"action": "removeLineItem", | ||
"lineItemId": "24de3821-e27d-4ddb-bd0b-ecc99365285f" | ||
}, | ||
{ | ||
"action": "addLineItem", | ||
"sku": "SKU-3", | ||
"quantity": 3, | ||
"addedAt": "2020-11-05T10:00:10.101Z", | ||
"custom": { | ||
"type": { | ||
"key": "custom-type-for-shoppinglists" | ||
}, | ||
"fields": { | ||
"textField": "text-3 | ||
} | ||
} | ||
} |
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 suppose it is going to remove existing 'sku-2' line item.
These two updateActions are appropriate. I am just curious how we determine which updateActions are needed in UpdateActionUtil
for each LineItem.
For example
existing line item : ['sku-4', 'sku-1', 'sku-2']
new line items : ['sku-3', 'sku-4', 'sku-1']
Besides adding 'sku-3' and removing 'sku-2', we have to remove 'sku-1', 'sku-4' from existing line items as well. Otherwise the order is not the same as expected.
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.
Good catch!, You are right, the scenario was the same as scenario 1. 97d4d15
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.
From your example, you checked sku-3 and sku-4 is different than to able to match the order, all actions need to be removed and added back because you need to ensure the order.
In scenario 1,
draft : [sku1,..., sku2]
target: [sku2...]
In scenario 2,
draft: [sku1,..., sku3, sku2]
target: [sku1,..., sku2]
sku1 is exactly the same until you find the first difference assume you have N same but a difference in the middle, you don't need to create actions for those N items, here how we will know the difference depends on the comparisons between draft and target objects, so it's like doing sequence comparisons with their order. During the implementation, I could find more examples and could add here.
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
…actions.md Co-authored-by: Lam Tran <lam.tran@commercetools.de>
Co-authored-by: Lam Tran <lam.tran@commercetools.de> Co-authored-by: King-Hin Leung <35692276+leungkinghin@users.noreply.github.com>
Can you add one more example - no new line item is added or removed, just order is different. What is the solution here? |
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
…actions.md Co-authored-by: Lam Tran <lam.tran@commercetools.de>
d4f24e6 I don't know the exact algorithm yet, but could be done by removing and adding back. |
@leungkinghin @lojzatran could you please re-check the latest updates: 1ef3339, 3902376, 6096a78 |
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
…actions.md Co-authored-by: Lam Tran <lam.tran@commercetools.de>
</p> | ||
<p> | ||
First example seems reasonable but how you would sync a case like: | ||
'[SKU-1, SKU-2, SKU-3]' to '[SKU-3, SKU-1, SKU-4, SKU-2]', so with a new algorithm it might be done with |
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.
'[SKU-1, SKU-2, SKU-3]' to '[SKU-3, SKU-1, SKU-4, SKU-2]', so with a new algorithm it might be done with | |
'[SKU-1, SKU-2, SKU-3]' to '[SKU-3, SKU-1, SKU-4, SKU-2]'? With a new algorithm it might be done with |
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.
What is the new algorithm?
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.
there is none: 98822a9
<p> | ||
First example seems reasonable but how you would sync a case like: | ||
'[SKU-1, SKU-2, SKU-3]' to '[SKU-3, SKU-1, SKU-4, SKU-2]', so with a new algorithm it might be done with | ||
change order [line-item-id-3, line-item-id-1, line-item-id-2] then removeLineItem SKU-2, add back addLineItem SKU-4, |
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.
Please make those actions bold and also in the array [], so we know there are 3 of them.
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.
in total 3 actions. | ||
</p> | ||
<p> | ||
It looks like there are more different cases and that's why we decided to keep the idea of removing and adding back to |
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.
It looks like there are more different cases and that's why we decided to keep the idea of removing and adding back to | |
It looks like there are more different cases. That's why we decided to keep the idea of removing and adding back to |
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.
Make the conclusion more dominant (bold, bigger font).
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.
now better: 98822a9
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
docs/adr/0002-shopping-lists-lineitem-and-textlineitem-update-actions.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Lam Tran <lam.tran@commercetools.de>
* master: Bump commercetoolsJvmSdkVersion from 1.54.0 to 1.55.0 Version updates and release notes of 3.0.0 (#620) 610 - Fix duration calculation for retry client. (+ refactor client creation logic) (#623) Add user guide for Shopping lists (#613) Cover shopping list line items in integration test scenarios (#626) Revert "Resolve ProductTypeSyncTest" wrapped <li> elements in <ul> tags (#616) Implement text line item actions (#625) Resolve ProductTypeSyncTest Implement LineItem actions (#618) Concept of the shopping lists' line item update actions. (#614) Bump assertj-core from 3.18.0 to 3.18.1 Implement Shoppinglist Sync class with IT/UT (exclude LineItem and TextLineItem) (#615) Add shopping list update actions (without line items) (#611) Create shoppinglist sync utils and helper (#595) Add ShoppingList Reference Resolver helpers/utilities. (#602)
Review Hint:
It would be better to check the file preview otherwise hard to understand because of the HTML source code in markdown.