This commit is contained in:
Matthias Hochmeister
2026-03-13 20:02:46 +01:00
parent 1b1a53cd8f
commit f5d1f7b061
3 changed files with 138 additions and 56 deletions

View File

@@ -10,9 +10,10 @@ function log(msg: string) {
* Returns null if no match found — the field will be left unchanged.
*/
function mapDienstgrad(raw: string): string | null {
const map: Record<string, string> = {
// Abbreviations
const abbrevMap: Record<string, string> = {
'fa': 'Feuerwehranwärter',
'jfm': 'Jugendfeuerwehrmann',
'pfm': 'Probefeuerwehrmann',
'fm': 'Feuerwehrmann',
'ff': 'Feuerwehrfrau',
'ofm': 'Oberfeuerwehrmann',
@@ -29,26 +30,33 @@ function mapDienstgrad(raw: string): string | null {
'obi': 'Oberbrandinspektor',
'boi': 'Brandoberinspektor',
'bam': 'Brandamtmann',
// Full names (pass-through if already matching)
'feuerwehranwärter': 'Feuerwehranwärter',
'feuerwehrmann': 'Feuerwehrmann',
'feuerwehrfrau': 'Feuerwehrfrau',
'oberfeuerwehrmann': 'Oberfeuerwehrmann',
'oberfeuerwehrfrau': 'Oberfeuerwehrfrau',
'hauptfeuerwehrmann': 'Hauptfeuerwehrmann',
'hauptfeuerwehrfrau': 'Hauptfeuerwehrfrau',
'löschmeister': 'Löschmeister',
'oberlöschmeister': 'Oberlöschmeister',
'hauptlöschmeister': 'Hauptlöschmeister',
'brandmeister': 'Brandmeister',
'oberbrandmeister': 'Oberbrandmeister',
'hauptbrandmeister': 'Hauptbrandmeister',
'brandinspektor': 'Brandinspektor',
'oberbrandinspektor': 'Oberbrandinspektor',
'brandoberinspektor': 'Brandoberinspektor',
'brandamtmann': 'Brandamtmann',
'vm': 'Verwaltungsmeister',
'ovm': 'Oberverwaltungsmeister',
'hvm': 'Hauptverwaltungsmeister',
'v': 'Verwalter',
};
return map[raw.trim().toLowerCase()] ?? null;
const normalized = raw.trim().toLowerCase();
// Direct abbreviation match
if (abbrevMap[normalized]) return abbrevMap[normalized];
// Ehrendienstgrad: starts with 'e', rest maps to a known abbreviation
// e.g. EOLM → Ehren-Oberlöschmeister, EVM → Ehren-Verwaltungsmeister
if (normalized.startsWith('e') && normalized.length > 1) {
const base = abbrevMap[normalized.slice(1)];
if (base) return `Ehren-${base}`;
}
// Full name pass-through (case-insensitive)
const allValues = Object.values(abbrevMap);
const match = allValues.find(v => v.toLowerCase() === normalized);
if (match) return match;
// Also match Ehren- full names
const ehrenMatch = allValues.find(v => `ehren-${v.toLowerCase()}` === normalized);
if (ehrenMatch) return `Ehren-${ehrenMatch}`;
return null;
}
export async function syncToDatabase(