Skip to content

Commit

Permalink
Sm/pr feedback 948 (#953)
Browse files Browse the repository at this point in the history
* fix: ut and better answers for case errors

* test: another case guess test
  • Loading branch information
mshanemc authored May 1, 2023
1 parent ef89026 commit 95584c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/registry/registryAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export class RegistryAccess {
): Array<{ suffixGuess: string; metadataTypeGuess: MetadataType }> | undefined {
const registryKeys = Object.keys(this.registry.suffixes);

const scores = registryKeys.map((registryKey) => ({ registryKey, score: Levenshtein.get(suffix, registryKey) }));
const scores = registryKeys.map((registryKey) => ({
registryKey,
score: Levenshtein.get(suffix, registryKey, { useCollator: true }),
}));
const sortedScores = scores.sort((a, b) => a.score - b.score);
const lowestScore = sortedScores[0].score;
// Levenshtein uses positive integers for scores, find all scores that match the lowest score
Expand Down
11 changes: 11 additions & 0 deletions test/registry/registryAccess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,15 @@ describe('RegistryAccess', () => {
expect(registryAccess.getParentType(registry.types.digitalexperienceconfig.id)).to.be.undefined;
});
});

describe('suggestions', () => {
it('guess for a type that is all uppercase should return the correct type first', () => {
const result = registryAccess.guessTypeBySuffix('CLS');
expect(result?.[0].metadataTypeGuess.name).to.equal('ApexClass');
});
it('guess for a type that is first-uppercase should return the correct type first', () => {
const result = registryAccess.guessTypeBySuffix('Cls');
expect(result?.[0].metadataTypeGuess.name).to.equal('ApexClass');
});
});
});

2 comments on commit 95584c7

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 95584c7 Previous: 0993bb2 Ratio
eda-componentSetCreate-linux 224 ms 326 ms 0.69
eda-sourceToMdapi-linux 4987 ms 7490 ms 0.67
eda-sourceToZip-linux 4689 ms 5559 ms 0.84
eda-mdapiToSource-linux 4109 ms 5939 ms 0.69
lotsOfClasses-componentSetCreate-linux 441 ms 686 ms 0.64
lotsOfClasses-sourceToMdapi-linux 8518 ms 10454 ms 0.81
lotsOfClasses-sourceToZip-linux 6641 ms 8190 ms 0.81
lotsOfClasses-mdapiToSource-linux 4872 ms 6955 ms 0.70
lotsOfClassesOneDir-componentSetCreate-linux 750 ms 1068 ms 0.70
lotsOfClassesOneDir-sourceToMdapi-linux 12236 ms 16942 ms 0.72
lotsOfClassesOneDir-sourceToZip-linux 9946 ms 13242 ms 0.75
lotsOfClassesOneDir-mdapiToSource-linux 8543 ms 12705 ms 0.67

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 95584c7 Previous: 0993bb2 Ratio
eda-componentSetCreate-win32 443 ms 690 ms 0.64
eda-sourceToMdapi-win32 8175 ms 10941 ms 0.75
eda-sourceToZip-win32 6083 ms 8371 ms 0.73
eda-mdapiToSource-win32 8177 ms 11746 ms 0.70
lotsOfClasses-componentSetCreate-win32 858 ms 1586 ms 0.54
lotsOfClasses-sourceToMdapi-win32 11376 ms 16260 ms 0.70
lotsOfClasses-sourceToZip-win32 8275 ms 11031 ms 0.75
lotsOfClasses-mdapiToSource-win32 9559 ms 13472 ms 0.71
lotsOfClassesOneDir-componentSetCreate-win32 1565 ms 2657 ms 0.59
lotsOfClassesOneDir-sourceToMdapi-win32 19678 ms 27296 ms 0.72
lotsOfClassesOneDir-sourceToZip-win32 12745 ms 18691 ms 0.68
lotsOfClassesOneDir-mdapiToSource-win32 17447 ms 24733 ms 0.71

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.