Skip to content

Commit 57da9a9

Browse files
committed
Move alias pick into chooseStep fn
These should be matched exactly and not go through the fuzzy matching
1 parent a83af7a commit 57da9a9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/pnp/findStepColumns.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sortBy } from '@seedcompany/common';
1+
import { mapOf, sortBy } from '@seedcompany/common';
22
import levenshtein from 'fastest-levenshtein';
33
import { startCase } from 'lodash';
44
import { type Column } from '~/common/xlsx.util';
@@ -7,7 +7,7 @@ import { type PnpExtractionResult, PnpProblemType } from './extraction-result';
77
import { type PlanningSheet } from './planning-sheet';
88
import { type ProgressSheet } from './progress-sheet';
99

10-
const ApprovedCustomSteps = new Map<string, Step>([
10+
const ApprovedAliases = mapOf<string, Step>([
1111
['draft & keyboard', Step.ExegesisAndFirstDraft],
1212
['first draft', Step.ExegesisAndFirstDraft],
1313
['exegesis, 1st draft, keyboard', Step.ExegesisAndFirstDraft],
@@ -38,9 +38,7 @@ export function findStepColumns(
3838
.walkRight()
3939
.filter((cell) => !!cell.asString)
4040
.map((cell) => ({
41-
label:
42-
ApprovedCustomSteps.get(cell.asString!.trim().toLowerCase()) ??
43-
cell.asString!,
41+
label: cell.asString!.trim(),
4442
column: cell.column,
4543
cell,
4644
}))
@@ -69,6 +67,11 @@ const chooseStep = (
6967
label: string,
7068
available: ReadonlySet<Step>,
7169
): Step | undefined => {
70+
const alias = ApprovedAliases.get(label.toLowerCase());
71+
if (alias) {
72+
return alias;
73+
}
74+
7275
const distances = available.values().map((step) => {
7376
const humanLabel = startCase(step).replace(' And ', ' & ');
7477
const distance = levenshtein.distance(label, humanLabel);

0 commit comments

Comments
 (0)