You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Remove LocationOriginTypes imports and usage across various files
- Simplify tag generation logic in update-article.ts
- Adjust tests and metafield creation/update to reflect removal of origin_type
- Update product orchestration to handle changes in locationType and day tags
- Remove LocationOriginTypes enum and its usage across various schemas and types.
- Introduce new location types: HOME, SALON, and VIRTUAL.
- Replace ORIGIN and ONLINE types with the new location types.
- Adjust tests and helper functions to reflect the updated location types.
3, because the PR involves multiple files and changes related to the removal of a data field across various services and tests. The logic changes in tag generation and data handling need careful review to ensure that all references are correctly updated and that no residual or broken code remains.
🧪 Relevant tests
Yes
⚡ Possible issues
Possible Bug: The removal of originType and changes in location types could lead to issues if not all instances are properly updated or if other parts of the system rely on the old data structure.
Consider adding error handling for the .map() function used in tag generation to ensure that the properties accessed on locations are not undefined, which could cause runtime errors. [important]
Since origin_type key is removed, ensure that no external integrations or database queries depend on this metafield to prevent breaking changes. [medium]
Prevent duplicate location ID tags by using a Set to ensure uniqueness
The current implementation may add duplicate locationid tags if the same location appears multiple times in the product.locations array. To prevent this, you can use a Set to ensure all tags are unique before converting them back to an array.
Why: This suggestion addresses a potential issue with duplicate tags, which can lead to incorrect or redundant data. Using a Set to ensure uniqueness is a good enhancement for data integrity.
9
Expand the enum list for location types to cover all use cases
Update the enum for locationType to include all possible types such as 'office' or 'warehouse' to cover all business cases.
Why: Expanding the enum list for location types is a good enhancement to cover more use cases, but it is not critical and depends on the actual business requirements.
6
Possible bug
Add a safeguard against undefined locationType properties in tag generation
Ensure that the locationType property is always defined before using it in the tag generation. This can prevent runtime errors if some locations do not have this property set. You can use optional chaining (?.) and provide a default value if needed.
Why: This suggestion adds a safeguard against potential runtime errors, which is important for robustness. It ensures that the code does not break if locationType is undefined.
8
Add checks to ensure day values are defined before processing to avoid errors
When generating the day tags from schedule.slots, consider handling potential undefined values in slot.day to avoid runtime errors. Implement a filter to exclude undefined or null values before converting them to lowercase and joining.
-const days = schedule.slots.map((slot) => slot.day.toLowerCase());+const days = schedule.slots+ .filter((slot) => slot.day)+ .map((slot) => slot.day.toLowerCase());
Suggestion importance[1-10]: 8
Why: This suggestion improves the robustness of the code by ensuring that undefined values are handled properly, preventing potential runtime errors. It adds necessary checks to ensure data integrity.
8
Best practice
Use a neutral default location type in test helpers
Ensure that the locationType in getLocationObject function defaults to a more neutral type like LocationTypes.DESTINATION instead of LocationTypes.HOME to avoid biased test data.
Why: Using a neutral default location type in test helpers is a best practice that ensures unbiased test data, which is important for accurate testing.
8
Performance
Optimize the generation of location type tags by reducing array iterations
Consider using a more efficient method for generating tags related to locationType. Currently, the code maps over locations twice: once for converting locationType to a string and again for joining them. This can be optimized by chaining these operations together in a single map function, reducing the overhead of multiple iterations over the array.
Why: The suggestion improves performance by reducing the number of iterations over the array, which is a minor but useful optimization. However, it does not address any critical issues or bugs.
7
Maintainability
Replace hardcoded location type with a variable for flexibility
Replace the hardcoded LocationTypes.HOME with a variable or a function parameter to increase flexibility and maintainability of the test setup.
Why: This suggestion improves maintainability by making the test setup more flexible. However, it is not crucial and does not address a major bug or issue.
7
Consistency
Review and update type definitions for consistency post-removal of origin types
Ensure consistency in the UserAggregationResult type by possibly including other relevant location-related properties that might have been overlooked due to the removal of LocationOriginTypes.
locationType: LocationTypes;
+additionalProperty: string; # Replace or modify as needed based on actual use case
Suggestion importance[1-10]: 5
Why: While ensuring consistency in type definitions is important, the suggestion is somewhat vague and speculative without specific context on what additional properties might be needed.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests, Documentation
Description
LocationOriginTypes
andoriginType
fields from various files, including schemas, services, and tests.HOME
,SALON
, andVIRTUAL
.update-article.ts
andupdate-product.ts
.originType
and the new location types.Changes walkthrough 📝
14 files
update-article.ts
Remove `LocationOriginTypes` and simplify tag generation.
src/functions/customer/orchestrations/customer/update/update-article.ts
LocationOriginTypes
and related logic.create-location-metafield.ts
Remove `originType` from location metafield creation.
src/functions/customer/orchestrations/location/create/create-location-metafield.ts
originType
field from metafield creation.update-location-metafield.ts
Remove `originType` from location metafield update.
src/functions/customer/orchestrations/location/update/update-location-metafield.ts
originType
field from metafield update.update-product.ts
Refactor product update logic and tag generation.
src/functions/customer/orchestrations/product/update/update-product.ts
CustomerProductServiceGet
import.aggregation.ts
Remove `originType` from booking aggregation.
src/functions/customer/services/booking/aggregation.ts
originType
from booking aggregation.range.ts
Remove `originType` from booking range type.
src/functions/customer/services/booking/range.ts
originType
from booking range type.get.ts
Remove `originType` from order service.
src/functions/customer/services/order/get.ts
originType
from order service.location.schema.ts
Update location schema to remove `originType`.
src/functions/location/location.schema.ts
originType
field from location schema.location.types.ts
Update location types to remove `LocationOriginTypes`.
src/functions/location/location.types.ts
LocationOriginTypes
enum.LocationTypes
enum with new values.schedule.types.ts
Remove `LocationOriginTypes` from schedule types.
src/functions/schedule/schedule.types.ts
LocationOriginTypes
from schedule types.product.schema.ts
Update product schema to remove `originType`.
src/functions/schedule/schemas/product.schema.ts
originType
field from product schema.search.ts
Remove `originType` from user search schema.
src/functions/user/controllers/user/search.ts
originType
from user search schema.filters.ts
Remove `originType` from user filters.
src/functions/user/services/user/filters.ts
originType
from user filters.search.ts
Remove `originType` from user search service.
src/functions/user/services/user/search.ts
originType
from user search service.14 files
create-location-metafield.spec.ts
Update tests to remove `LocationOriginTypes`.
src/functions/customer/orchestrations/location/create/create-location-metafield.spec.ts
LocationOriginTypes
from tests.update-location-metafield.spec.ts
Update tests to remove `LocationOriginTypes`.
src/functions/customer/orchestrations/location/update/update-location-metafield.spec.ts
LocationOriginTypes
from tests.update-product.spec.ts
Update product tests for new location types and day tags.
src/functions/customer/orchestrations/product/update/update-product.spec.ts
create.spec.ts
Update location creation tests for new location types.
src/functions/customer/services/location/create.spec.ts
LocationOriginTypes
from tests.get-products.spec.ts
Remove `originType` from location product tests.
src/functions/customer/services/location/get-products.spec.ts
originType
from location product tests.add.spec.ts
Remove `LocationOriginTypes` from product add tests.
src/functions/customer/services/product/add.spec.ts
LocationOriginTypes
from product add tests.remove-location-from-all.spec.ts
Update product removal tests for new location types.
src/functions/customer/services/product/remove-location-from-all.spec.ts
LocationOriginTypes
from product removal tests.get.spec.ts
Remove `LocationOriginTypes` from shipping service tests.
src/functions/shipping/services/get.spec.ts
LocationOriginTypes
from shipping service tests.generate.spec.ts
Update availability generation tests for new location types.
src/functions/user/services/availability/generate.spec.ts
LocationOriginTypes
from availability generation tests.get.spec.ts
Update availability get tests for new location types.
src/functions/user/services/availability/get.spec.ts
LocationOriginTypes
from availability get tests.filters.spec.ts
Remove `originType` from user filters tests.
src/functions/user/services/user/filters.spec.ts
originType
from user filters tests.search.spec.ts
Remove `originType` from user search tests.
src/functions/user/services/user/search.spec.ts
originType
from user search tests.location.ts
Remove `LocationOriginTypes` from location helpers.
src/library/jest/helpers/location.ts
LocationOriginTypes
from location helpers.product.ts
Remove `LocationOriginTypes` from product helpers.
src/library/jest/helpers/product.ts
LocationOriginTypes
from product helpers.7 files
update.ts
Add TODO for updating day tags in products.
src/functions/customer/orchestrations/schedule/update.ts
base-location.yaml
Update base location schema to remove `originType`.
openapi/paths/customer/location/_types/base-location.yaml
originType
field from location schema.body.yaml
Update location creation schema to remove `originType`.
openapi/paths/customer/location/create/body.yaml
originType
field from location creation schema.body.yaml
Update location update schema to remove `originType`.
openapi/paths/customer/location/update/body.yaml
originType
field from location update schema.product-locations.yaml
Update product locations schema to remove `originType`.
openapi/paths/customer/schedule/_types/product-locations.yaml
originType
field from product locations schema.payload.yaml
Update user filters payload to remove `originType`.
openapi/paths/user/filters/payload.yaml
originType
field from user filters payload.body.yaml
Update user search body to remove `originType`.
openapi/paths/user/search/body.yaml
originType
field from user search body.