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

fix: return from skuFromRefIds #169

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: return from skuFromRefIds
  • Loading branch information
giurigaud authored and ataideverton committed Oct 2, 2024
commit 97e325bbe3271833182a69ce729d670b64347e46
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"eslint.validate": [
"javascript",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed

- Fixed the return from skuFromRefIds and improve the return from getSkuSellerInfo

## [3.15.7] - 2024-09-26

Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"dependencies": {
"@gocommerce/utils": "^0.7.3",
"@vtex/api": "6.46.1",
"@vtex/api": "6.47.0",
"atob": "^2.1.2",
"axios": "^0.19.0",
"camelcase": "^5.0.0",
Expand Down
20 changes: 15 additions & 5 deletions node/resolvers/search/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ const getSkuSellerInfo = (simulationResults: any, result: any) => {

if (Object.keys(simulationResults).length !== 0) {
items = result.map((item: any) => {
const skuInfoBySeller = item.sellers?.map((seller: any) => {
const skuInfoBySeller = item.sellers?.flatMap((seller: any) => {
if (!simulationResults[item.sku]) {
return null
return [];
}

const currSeller = simulationResults[item.sku].sellers.find(
Expand All @@ -210,7 +210,7 @@ const getSkuSellerInfo = (simulationResults: any, result: any) => {

return {
...item,
sellers: item.sellers ? skuInfoBySeller : null,
sellers: skuInfoBySeller,
}
})
}
Expand Down Expand Up @@ -297,8 +297,18 @@ export const queries = {
},
ctx
).then(simulationResults => {
// include SKU's availability and unit multiplier info in given seller
items = getSkuSellerInfo(simulationResults, result)
if (Object.keys(simulationResults).length !== 0) {
// include SKU's availability and unit multiplier info in given seller
items = getSkuSellerInfo(simulationResults, result)
} else {
items = result.map((item: { sellers: any[] }) => ({
...item,
sellers: item.sellers?.filter((seller: any) =>
'availability' in seller &&
seller.availability !== null
) || []

Choose a reason for hiding this comment

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

could you add a comment explaining what/why we are doing here exactly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}))
}
})
} catch (error) {
logger.error({
Expand Down
10 changes: 5 additions & 5 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1863,10 +1863,10 @@
resolved "https://registry.yarnpkg.com/@types/zen-observable/-/zen-observable-0.8.0.tgz#8b63ab7f1aa5321248aad5ac890a485656dcea4d"
integrity sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==

"@vtex/api@6.46.1":
version "6.46.1"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.46.1.tgz#55a8755ae48f5400e7f1ed1921cd547950bb7a2a"
integrity sha512-geoxVvyWoQpOQ70Zmx3M8SBkRoGOS/bp9Gy26M+iCue63jofVSwmFz1zf66EaHA1PKOJNRgQPFwY+oeDE1U2lQ==
"@vtex/api@6.47.0":
version "6.47.0"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.47.0.tgz#6910455d593d8bb76f1f4f2b7660023853fda35e"
integrity sha512-t9gt7Q89EMbSj3rLhho+49Fv+/lQgiy8EPVRgtmmXFp1J4v8hIAZF7GPjCPie111KVs4eG0gfZFpmhA5dafKNA==
dependencies:
"@types/koa" "^2.11.0"
"@types/koa-compose" "^3.2.3"
Expand Down Expand Up @@ -6071,7 +6071,7 @@ static-extend@^0.1.1:
define-property "^0.2.5"
object-copy "^0.1.0"

stats-lite@vtex/node-stats-lite#dist:
"stats-lite@github:vtex/node-stats-lite#dist":
version "2.2.0"
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/1b0d39cc41ef7aaecfd541191f877887a2044797"
dependencies:
Expand Down