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(utils): add campaign + promotion create / update #6077

Merged
merged 9 commits into from
Jan 16, 2024

Conversation

riqwan
Copy link
Contributor

@riqwan riqwan commented Jan 12, 2024

RESOLVES CORE-1637
RESOLVES CORE-1638

Copy link

vercel bot commented Jan 12, 2024

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

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2024 6:11pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Jan 15, 2024 6:11pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Jan 15, 2024 6:11pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Jan 15, 2024 6:11pm

Copy link

changeset-bot bot commented Jan 12, 2024

🦋 Changeset detected

Latest commit: 51d62e1

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

This PR includes changesets to release 1 package
Name Type
@medusajs/types 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
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

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

LGTM, only a couple of questions :)

@@ -8,4 +10,60 @@ export class CampaignRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: CreateCampaignDTO
update: UpdateCampaignDTO
}
>(Campaign) {}
>(Campaign) {
async create(
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Shouldn't this logic live at the service level as per our convention? Or is this a special case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to add promotions to the campaign collection (through .add()), which is purely dependent on MikroORM. If we add it to the service, we make the service mikroorm dependent.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking was if a feature of the module is to be able to create a campaign with promotions using a single service method, then this should be decoupled from MikroORM no? Otherwise, the behavior of service.createCampaigns would differ depending on what ORM you choose, which I wouldn't expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think we're aligned on that. But it is true that ORMs handle one to many or many to many relationships differently. Shouldn't we just have to ensure that we pass a consistent shape to the repository layer and then the repositories handle them based on how they process relationships?

@riqwan riqwan changed the title feat(utils): add campaign + promotion create feat(utils): add campaign + promotion create / update Jan 15, 2024
@riqwan
Copy link
Contributor Author

riqwan commented Jan 15, 2024

@adrien2p @pKorsholm can you guys take a look at this PR?

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, just a couple of nits 😄

@riqwan riqwan merged commit e28fa7f into develop Jan 16, 2024
16 checks passed
@riqwan riqwan deleted the feat/campaign-promotion branch January 16, 2024 08:38
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.

3 participants