Search: typo tolerance only against name words, and only for words with no exact hit (QA C26)
Since #206 the search compared every query word of five or more letters against every word of the exercise's corpus, body part, target and equipment included. A correctly spelled word one edit away from one of those shared words matched a whole slice of the catalogue: "wrist" ~ "waist" listed all 169 abs exercises (200 results instead of 31, the first real wrist curl on row 23), "power" ~ "lower arms" 174 instead of 2, "slide" ~ "side" 34 instead of 1, and in the German UI "drücken" ~ "rücken" returned every back exercise. Even words with exact hits picked up strays: "squat" led with "all fours squad stretch", "clean" gained "lean planche". The typo tolerance now compares against the exercise's own name words only (English and localized), never body part, target, equipment or description. Lists (library, exercise picker, muscle explorer) go through the new searchExercises: a word that appears literally in at least one exercise of the list is taken at its word, and only a word with no exact hit anywhere ("bnech", "dumbell", "wirst") falls back to the typo tolerance, so real matches are never buried under fuzzy ones. matchExercise keeps working per exercise for the progress picker. The existing typo tests keep passing unchanged. Rig (412 px, /#/library, fresh guest, rows rendered / first genuine row) before -> after: wrist 40+/23 -> 31/1, power 40+/none -> 2/1, slide 34/33 -> 1/1, thigh 17/none -> 1/1, squat "squad" first -> "band one arm single leg split squat" first, clean 12 -> 11, de "drücken" 40+ -> 0; typo queries "wirst curl" 26, "dumbell" 40+, "bnech press" 33 still find their exercises. Cost per full pass 6 ms -> 0.8-2.5 ms.
This commit is contained in:
1 parent
83b2a140d6
commit
6e2dad2dc9
5 files changed
+91
-16
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useStore } from './store/useStore.js'
|
||||
import { useUI } from './store/useUI.js'
|
||||
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise, exOr } from './lib/exercises.js'
|
||||
import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, searchExercises, exOr } from './lib/exercises.js'
|
||||
import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js'
|
||||
import { fmtDate, fmtNum, capWords, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js'
|
||||
import { lastEntryFor, bestWeightFor, bestWeightForEntry, buildSets, effectiveRoutineIds, workoutVolume, setsDone, setsDoneActive, setUnitsTotal, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js'
|
||||
@@ -887,7 +887,7 @@ function ExercisePicker({ onPick, close }) {
|
||||
const all = allExercises(st)
|
||||
const profile = activeProfile(st)
|
||||
const inScope = e => bp === '★' ? usage[e.id] : bp === '☆' ? isFav(st, e.id) : (!bp || e.bp === bp)
|
||||
let base = all.filter(e => inScope(e) && matchExercise(e, q))
|
||||
let base = searchExercises(all.filter(inScope), q)
|
||||
if (bp === '★') base = [...base].sort((a, b) => (usage[b.id] - usage[a.id]) || exerciseNameFor(a).localeCompare(exerciseNameFor(b)))
|
||||
const eqFiltered = (profile && !showAll) ? base.filter(e => exAvailable(st, e)) : base
|
||||
const eqOpts = equipmentOf(eqFiltered)
|
||||
|
||||
Reference in new issue
Block a user