Skip to content

Commit

Permalink
Update per recommended changes to simplify mapping and clarify testin…
Browse files Browse the repository at this point in the history
…g case.
  • Loading branch information
brysonjbest committed Jul 24, 2024
1 parent a14d288 commit dfd9057
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/api/ruleMapping/ruleMapping.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('RuleMappingService', () => {
type: 'expressionNode',
content: {
expressions: [
{ key: 'expr1', value: 'field3' },
{ key: 'expr1', value: 'field3 > 5' },
{ key: 'expr2', value: 'complexExpr + 2' },
],
},
Expand All @@ -157,7 +157,7 @@ describe('RuleMappingService', () => {
const result = await service.extractFields(nodes, 'inputs');
expect(result).toEqual({
inputs: [
{ key: 'expr1', property: 'field3', exception: null },
{ key: 'expr1', property: 'expr1', exception: 'field3 > 5' },
{ key: 'expr2', property: 'expr2', exception: 'complexExpr + 2' },
],
});
Expand Down
6 changes: 1 addition & 5 deletions src/api/ruleMapping/ruleMapping.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export class RuleMappingService {
const results = await Promise.all(promises);
const fields = results.flat();

const uniqueFieldsMap = new Map<string, any>();

fields.forEach((field) => {
uniqueFieldsMap.set(field.property, field);
});
const uniqueFieldsMap = new Map(fields.map((field) => [field.property, field]));

const uniqueFields = Array.from(uniqueFieldsMap.values());
return { [fieldKey]: uniqueFields };
Expand Down

0 comments on commit dfd9057

Please sign in to comment.