Skip to content

Commit

Permalink
fixed the case where multiple select field contains null value
Browse files Browse the repository at this point in the history
  • Loading branch information
cs-raj committed Nov 11, 2024
1 parent 21a8afa commit 0578df2
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 276 deletions.
177 changes: 55 additions & 122 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.7.2 darwin-arm64 node-v22.2.0
@contentstack/cli-audit/1.7.3 darwin-arm64 node-v22.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.7.2",
"version": "1.7.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -27,7 +27,7 @@
"fs-extra": "^11.2.0",
"lodash": "^4.17.21",
"uuid": "^9.0.1",
"winston": "^3.16.0"
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-dev-dependencies": "^1.2.4",
Expand Down
21 changes: 12 additions & 9 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,24 +890,27 @@ export default class Entries {
}

/**
*
* this is called in case the select field has multiple optins to chose from
* @param field It contains the value to be searched
* @param selectOptions It contains the options that were added in CT
* @returns An Array of entry containing only the values that were present in CT, An array of not present entries
*/
findNotPresentSelectField(field: any, selectOptions: any) {
if(!field){
field = []
}
let present = [];
let notPresent = [];
const choicesMap = new Map(selectOptions.choices.map((choice: { value: any }) => [choice.value, choice]));
for (const value of field) {
const choice: any = choicesMap.get(value);

if (choice) {
present.push(choice.value);
} else {
notPresent.push(value);
for (const value of field) {
const choice: any = choicesMap.get(value);

if (choice) {
present.push(choice.value);
} else {
notPresent.push(value);
}
}
}
return { filteredFeild: present, notPresent };
}

Expand Down
Loading

0 comments on commit 0578df2

Please sign in to comment.