Fix naming of classes and groups in CSV parser

This commit is contained in:
Christian Wolf 2022-11-16 10:23:10 +01:00
parent 38c8e757ba
commit ffba4087e7
3 changed files with 55 additions and 5 deletions

View File

@ -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",

View File

@ -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."
}

View File

@ -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)