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

feat(orchestration,core-flows,medusa,product,types,utils): product import/export uses workflows #5811

Merged
merged 16 commits into from
Dec 12, 2023

Conversation

riqwan
Copy link
Contributor

@riqwan riqwan commented Dec 6, 2023

No description provided.

Copy link

changeset-bot bot commented Dec 6, 2023

🦋 Changeset detected

Latest commit: ec7f1c5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@medusajs/orchestration Patch
@medusajs/core-flows Patch
@medusajs/medusa Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Dec 12, 2023 11:47am
docs-ui ⬜️ Ignored (Inspect) Visit Preview Dec 12, 2023 11:47am
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Dec 12, 2023 11:47am

@riqwan riqwan marked this pull request as ready for review December 7, 2023 10:34
@riqwan riqwan requested a review from a team as a code owner December 7, 2023 10:34
@riqwan riqwan requested review from adrien2p and pKorsholm December 7, 2023 10:34
Copy link
Contributor

@pKorsholm pKorsholm left a comment

Choose a reason for hiding this comment

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

I have a couple of changes that I would like to see but it looks great! I really like the refactoring of the module-queries into utils 💪

@olivermrbl olivermrbl requested a review from adrien2p December 11, 2023 07:56
@riqwan riqwan changed the title feat(orchestration,core-flows,medusa): product import uses workflows feat(orchestration,core-flows,medusa): product import/export uses workflows Dec 11, 2023
@riqwan riqwan changed the title feat(orchestration,core-flows,medusa): product import/export uses workflows feat(orchestration,core-flows,medusa,product,types,utils): product import/export uses workflows Dec 11, 2023
@riqwan riqwan requested a review from pKorsholm December 11, 2023 10:54
Copy link
Contributor

@pKorsholm pKorsholm left a comment

Choose a reason for hiding this comment

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

lgtm

@riqwan riqwan requested a review from olivermrbl December 12, 2023 08:03
@olivermrbl
Copy link
Contributor

@riqwan feel free to merge as you please :)

for (const [
product_id,
variantsUpdateData = [],
] of productVariantsMap.entries()) {
Copy link
Member

Choose a reason for hiding this comment

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

todo: entries is not required, a map is iterable and will return the entries

Copy link
Member

@adrien2p adrien2p left a comment

Choose a reason for hiding this comment

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

LGTM, I have a few todo as well

@@ -37,6 +36,7 @@ export default class ProductExportStrategy extends AbstractBatchJobStrategy {
protected readonly productService_: ProductService
protected readonly fileService_: IFileService
protected readonly featureFlagRouter_: FlagRouter
protected readonly remoteQuery_: any
Copy link
Member

Choose a reason for hiding this comment

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

todo: We have a type for the remoteQuery if I am correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will address this in a follow up PR, saw this too late.

Copy link
Member

Choose a reason for hiding this comment

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

@riqwan have you done the followup pr?

;[productList, count] = await this.productService_
.withTransaction(transactionManager)
.listAndCount(filterable_fields, {
...(list_config ?? {}),
Copy link
Member

Choose a reason for hiding this comment

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

todo: since listConfig has a default value being {}. we can remove ?? {} right?

filterable_fields,
{
...list_config,
take: null,
Copy link
Member

@adrien2p adrien2p Dec 12, 2023

Choose a reason for hiding this comment

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

todo: why don't we use the take here? the issue is that we are fetching everything here

{
...list_config,
skip: offset,
take: Math.min(productCount - offset, limit),
Copy link
Member

Choose a reason for hiding this comment

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

todo: move that to a const above to be used in both cases

@@ -565,6 +616,10 @@ class ProductImportStrategy extends AbstractBatchJobStrategy {
return
}

const isMedusaV2Enabled = this.featureFlagRouter_.isFeatureEnabled(
Copy link
Member

Choose a reason for hiding this comment

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

todo: should we move that on the class level to be accessible everywhere? like a getter for example

await this.productVariantService_
.withTransaction(transactionManager)
.create(product!, variant as unknown as CreateProductVariantInput)
if (isMedusaV2Enabled) {
Copy link
Member

Choose a reason for hiding this comment

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

todo: In general, the workflows accept a collection of element, we should use that batch approach in a follow up pr. cc @olivermrbl @carlos-r-l-rodrigues


export function createContainerLike(obj): ContainerLike {
return {
resolve(key: string) {
Copy link
Member

Choose a reason for hiding this comment

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

todo: resolve<T = unknown>(key: string): T

@kodiakhq kodiakhq bot merged commit 07107f3 into develop Dec 12, 2023
15 checks passed
@kodiakhq kodiakhq bot deleted the feat/product-import-workflows branch December 12, 2023 12:09
@github-actions github-actions bot mentioned this pull request Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants