diff --git a/src/solo_turnier/tests/worker/csvImport.json b/src/solo_turnier/tests/worker/csvImport.json index 79fc8dc..e90bc83 100644 --- a/src/solo_turnier/tests/worker/csvImport.json +++ b/src/solo_turnier/tests/worker/csvImport.json @@ -24,6 +24,26 @@ "Beginner", "" ], + [ + "", + "19.06.2022", + "Kin.", + "Newcomer", + "Cha Cha", + "2", + "Max", + "Mustermann 1", + "", + "", + "Club A", + "TRP", + "1", + "1", + "0", + "Kin.", + "Beginner", + "" + ], [ "", "19.06.2022", diff --git a/src/solo_turnier/tests/worker/csvImportResult.json b/src/solo_turnier/tests/worker/csvImportResult.json index ac1d52e..4f12717 100644 --- a/src/solo_turnier/tests/worker/csvImportResult.json +++ b/src/solo_turnier/tests/worker/csvImportResult.json @@ -9,10 +9,24 @@ "place": "1", "placeTo": "1", "group": "Kin.", - "class_": "Beginner", + "class_": "Beg.", "competitionGroup": "Kin.", "competitionClass": "Newc./Beg." }, + { + "dance": "Cha Cha", + "id": "2", + "firstName": "Max", + "lastName": "Mustermann 1", + "name": "Max Mustermann 1", + "club": "Club A", + "place": "1", + "placeTo": "1", + "group": "Kin.", + "class_": "Beg.", + "competitionGroup": "Kin.", + "competitionClass": "Newc." + }, { "dance": "Cha Cha", "id": "3", @@ -23,7 +37,7 @@ "place": "3", "placeTo": "3", "group": "Kin.", - "class_": "Beginner", + "class_": "Beg.", "competitionGroup": "Kin.", "competitionClass": "Newc./Beg." } diff --git a/src/solo_turnier/worker.py b/src/solo_turnier/worker.py index 9a948d7..e65314b 100644 --- a/src/solo_turnier/worker.py +++ b/src/solo_turnier/worker.py @@ -109,20 +109,36 @@ class CompetitionResult: class CSVExtractor: def __init__(self): self.l = logging.getLogger('solo_turnier.worker') + self.__groupMaps = { + 'Kinder': 'Kin.', + 'Junioren': 'Jun.', + 'Jugend': 'Jug.' + } + self.__classMaps = { + 'Newcomer': 'Newc.', + 'Beginner': 'Beg.', + 'Advanced': 'Adv.' + } + def __mapGroup(self, group): + return self.__groupMaps.get(group, group) + + def __mapClass(self, class_): + return self.__classMaps.get(class_, class_) + def mapCSVImport(self, imported) -> list[ResultRow]: ret = [] def __processRow(row): result = ResultRow( - competitionGroup=row[2], - competitionClass=row[3], + competitionGroup=self.__mapGroup(row[2]), + competitionClass=self.__mapClass(row[3]), dance=row[4], id=row[5], firstName=row[6], lastName=row[7], club=row[10], place=row[12], placeTo=row[13], - group=row[15], class_=row[16] + group=self.__mapGroup(row[15]), class_=self.__mapClass(row[16]) ) ret.append(result) self.l.debug('Found row in CSV: %s', result)