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

chore(core): refactor merchant data structure #3906

Merged
merged 2 commits into from
Feb 2, 2024

Conversation

nicolasburtey
Copy link
Member

@nicolasburtey nicolasburtey commented Jan 28, 2024

moving the title/coordinate out of Account and into its own collection.
This is - in follow up PR - enables:

  • to have "merchant" been approved in the admin panel where all the data would be prefilled from the user directly (remove burden on the support side)
  • to have, for a single username, multiple point of the maps
  • we're now using geoprimitive for storing locations on mongodb, which would make search possible if we eventually only want to return part of the world instead of systematically all
  • the code is generally cleaner
  • adding tests (both bats and services)

@nicolasburtey nicolasburtey force-pushed the chore(core)--refactor-merchant-data-structure branch 5 times, most recently from 0f34c14 to a9c7c52 Compare January 31, 2024 21:14
core/api/test/integration/services/merchant.spec.ts Dismissed Show dismissed Hide dismissed
core/api/test/integration/services/merchant.spec.ts Dismissed Show dismissed Hide dismissed
@nicolasburtey nicolasburtey force-pushed the chore(core)--refactor-merchant-data-structure branch 3 times, most recently from b3f5a10 to 266f77c Compare February 1, 2024 02:52
chore: remove redundant describe

test: first integration test for add merchant

chore: add migration (untested yet)
@nicolasburtey nicolasburtey force-pushed the chore(core)--refactor-merchant-data-structure branch from 266f77c to d275287 Compare February 1, 2024 03:01
@nicolasburtey
Copy link
Member Author

when approved I will do a small iteration on the admin panel

@nicolasburtey nicolasburtey marked this pull request as ready for review February 1, 2024 03:07
return merchants
}

// TODO: manage multiple merchants for a single username
Copy link
Member Author

Choose a reason for hiding this comment

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

will be done on follow up PRs, right now it's mostly a refactor

core/api/src/app/accounts/mark-account-for-deletion.ts Outdated Show resolved Hide resolved
core/api/src/services/mongoose/schema.ts Show resolved Hide resolved
core/api/src/services/mongoose/merchants.ts Outdated Show resolved Hide resolved
core/api/src/services/mongoose/merchants.ts Outdated Show resolved Hide resolved
core/api/src/services/mongoose/merchants.ts Outdated Show resolved Hide resolved
id,
}: {
id: MerchantId
}): Promise<void | ApplicationError> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

In these sorts of cases we usually return true instead of void so that we don't miss any accidental early returns

Suggested change
}): Promise<void | ApplicationError> => {
}): Promise<true | ApplicationError> => {

Copy link
Member Author

Choose a reason for hiding this comment

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

that's a good point

Copy link
Member Author

@nicolasburtey nicolasburtey Feb 2, 2024

Choose a reason for hiding this comment

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

seems there are other place in the codebase that have Promise<void

core/api/src/app/merchants/delete-business-map-info.ts Outdated Show resolved Hide resolved
core/api/src/app/merchants/delete-business-map-info.ts Outdated Show resolved Hide resolved
return
}

export const deleteMerchantByUsername = async ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit, consistent naming

Suggested change
export const deleteMerchantByUsername = async ({
export const deleteMerchantLocationsByUsername = async ({

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd prefer to keep it deleteMerchantByUsername for now because there is no dis-association as of now between a merchant and a location

@nicolasburtey nicolasburtey merged commit 0318d21 into main Feb 2, 2024
14 checks passed
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.

2 participants