feat: add hevy map import to csv import
This commit is contained in:
1 parent
45f7541508
commit
687ef2562e
6 files changed
+369
-18
No files matched your search
@@ -209,32 +209,44 @@ async function main() {
|
||||
}
|
||||
|
||||
const map = {}
|
||||
const titleMap = {}
|
||||
const unmatched = []
|
||||
for (const t of templates) {
|
||||
if (!t?.id || t.is_custom) { if (t?.id && t.is_custom) unmatched.push(t); continue }
|
||||
const id = resolve(t)
|
||||
if (id) map[t.id] = id
|
||||
else unmatched.push(t)
|
||||
if (id) {
|
||||
map[t.id] = id
|
||||
const titleKey = String(t.title || '').trim().toLowerCase()
|
||||
if (titleKey && !titleMap[titleKey]) titleMap[titleKey] = id
|
||||
} else unmatched.push(t)
|
||||
}
|
||||
|
||||
// Stable key order for readable diffs.
|
||||
const keys = Object.keys(map).sort()
|
||||
const lines = keys.map(k => ` ${JSON.stringify(k)}: ${JSON.stringify(map[k])},`)
|
||||
const titleKeys = Object.keys(titleMap).sort()
|
||||
const titleLines = titleKeys.map(k => ` ${JSON.stringify(k)}: ${JSON.stringify(titleMap[k])},`)
|
||||
|
||||
const body = `// AUTO-GENERATED by scripts/build-hevy-id-map.mjs — do not edit by hand.
|
||||
// Hevy exercise_template id → openGym catalogue id.
|
||||
// Regenerated from the Hevy templates API + verified title aliases.
|
||||
// Hevy exercise_template id → openGym catalogue id, plus English title → id for CSV exports
|
||||
// (Hevy CSV has titles, not template ids). Regenerated from the Hevy templates API +
|
||||
// verified title aliases.
|
||||
// ${keys.length} mapped · ${unmatched.length} left unmatched (import as custom).
|
||||
// Source templates: ${templates.length} (built-in only).
|
||||
|
||||
export const HEVY_ID_MAP = {
|
||||
${lines.join('\n')}
|
||||
}
|
||||
|
||||
/** Lowercased Hevy English title → catalogue id (CSV / name path). */
|
||||
export const HEVY_TITLE_MAP = {
|
||||
${titleLines.join('\n')}
|
||||
}
|
||||
`
|
||||
|
||||
writeFileSync(OUT, body)
|
||||
console.log(`Wrote ${OUT}`)
|
||||
console.log(`Mapped ${keys.length} / ${templates.filter(t => !t.is_custom).length}`)
|
||||
console.log(`Mapped ${keys.length} / ${templates.filter(t => !t.is_custom).length} (titles ${titleKeys.length})`)
|
||||
console.log(`Unmatched ${unmatched.length} (become custom on import)`)
|
||||
if (process.env.VERBOSE) {
|
||||
unmatched.slice(0, 40).forEach(t => console.log(' -', t.title, `[${t.equipment}]`))
|
||||
|
||||
Reference in new issue
Block a user