Added file changes made live during competition to make things run smoothly

This commit is contained in:
Christian Wolf 2023-11-13 09:31:43 +01:00
parent 82fabe69a7
commit 8298cd85a8
2 changed files with 63 additions and 19 deletions

View File

@ -61,6 +61,9 @@ class HtmlParticipant:
def __hash__(self): def __hash__(self):
return hash((self.id, self.name)) return hash((self.id, self.name))
def __gt__(self, other):
return self.id >= other.id
# class PreviewParticipationData: # class PreviewParticipationData:
# def __init__(self, dance: str, class_: competition_class.CompetitionClass): # def __init__(self, dance: str, class_: competition_class.CompetitionClass):
# self.class_ = class_ # self.class_ = class_
@ -145,6 +148,15 @@ class HtmlSingleCompetitionResult:
else: else:
return f'Res({self.name}, placed {place})' return f'Res({self.name}, placed {place})'
def __gt__(self,other):
return self.id > other.id
def __eq__(self, other):
return self.id == other.id
def __hash__(self):
return hash(self.id)
class HtmlCompetitionTotalResults: class HtmlCompetitionTotalResults:
def __init__(self): def __init__(self):
self.results = {} self.results = {}

View File

@ -456,7 +456,7 @@ class Worker:
dances = self._extractDancesPerGroup(importedData, group) dances = self._extractDancesPerGroup(importedData, group)
self.l.log(5, 'Found dances in group %s: %s', group, dances) self.l.log(5, 'Found dances in group %s: %s', group, dances)
participants = self._extractParticipantsPerGroup(importedData.previewImport, group) participants = self._extractParticipantsPerGroup(importedData, group)
self.l.log(5, 'Related participants %s', participants) self.l.log(5, 'Related participants %s', participants)
results = {} results = {}
@ -485,24 +485,35 @@ class Worker:
def _extractGroups(self, data: types.State3): def _extractGroups(self, data: types.State3):
groupParser = solo_turnier.group.GroupParser()
groupSet = set([]) groupSet = set([])
for id in data.previewImport.participants: # for id in data.previewImport.participants:
participants = data.previewImport.participants[id] # participants = data.previewImport.participants[id]
for participant in participants: # for participant in participants:
groupSet.add(participant.group) # groupSet.add(participant.group)
for tup in data.htmlResults.results.keys():
gr = groupParser.parseClass(tup[0])
groupSet.add(gr)
# self.l.log(5, 'Group type %s', type(gr))
self.l.log(5, 'Set of active groups: %s', groupSet) self.l.log(5, 'Set of active groups: %s', groupSet)
groupParser = solo_turnier.group.GroupParser()
groups = groupParser.getGroupsAsSortedList(groupSet) groups = groupParser.getGroupsAsSortedList(groupSet)
return groups return groups
def _extractDancesPerGroup(self, data: types.State3, group: solo_turnier.group.Group): def _extractDancesPerGroup(self, data: types.State3, group: solo_turnier.group.Group):
groupParser = solo_turnier.group.GroupParser()
dances = set() dances = set()
additionalDances = set() additionalDances = set()
for part in data.previewImport.results.keys(): for tup in data.htmlResults.results.keys():
allFoundDances = set(data.previewImport.results[part].keys()) if not groupParser.parseClass(tup[0]) == group:
dances.update(allFoundDances.intersection(self._allDances)) continue
additionalDances.update(allFoundDances.difference(self._allDances)) dances.add(tup[2])
# for part in data.previewImport.results.keys():
# allFoundDances = set(data.previewImport.results[part].keys())
# dances.update(allFoundDances.intersection(self._allDances))
# additionalDances.update(allFoundDances.difference(self._allDances))
if len(additionalDances) > 0: if len(additionalDances) > 0:
self.l.warning('There were dances found, that are not registered. A bug? The dances were: %s', additionalDances) self.l.warning('There were dances found, that are not registered. A bug? The dances were: %s', additionalDances)
@ -514,27 +525,45 @@ class Worker:
def _extractParticipantsPerGroup( def _extractParticipantsPerGroup(
self, self,
previewData: types.HtmlPreviewImport, importedData: types.State3,
# previewData: types.HtmlPreviewImport,
group: solo_turnier.group.Group group: solo_turnier.group.Group
) -> list[types.HtmlPreviewParticipant]: ) -> list[types.HtmlPreviewParticipant]:
groupParser = types.group.GroupParser()
ret = [] ret = []
for id in previewData.participants:
participantList = previewData.participants[id] self.l.log(5, 'Table %s', pformat(importedData.htmlResults.tabges))
for participant in participantList: self.l.log(5, 'Results %s', pformat(importedData.htmlResults.results))
if participant.group == group:
ret.append(participant) for tup in importedData.htmlResults.results.keys():
gr = groupParser.parseClass(tup[0])
if not gr == group:
continue
part = importedData.htmlResults.results[tup][0]
part.id = int(tup[3])
ret.append(part)
self.l.log(5, 'ret %s', ret)
# raise Exception('Test')
# for id in previewData.participants:
# participantList = previewData.participants[id]
# for participant in participantList:
# if participant.group == group:
# ret.append(participant)
return ret return ret
def _getResultOfSingleParticipant( def _getResultOfSingleParticipant(
self, self,
participant: types.HtmlPreviewParticipant, participant: types.HtmlParticipant,
nominalGroup: solo_turnier.group.Group, nominalGroup: solo_turnier.group.Group,
previewResults: types.HtmlPreviewImport, previewResults: types.HtmlPreviewImport,
totalResults: types.HtmlCompetitionTotalResults, totalResults: types.HtmlCompetitionTotalResults,
allDances: list[str] allDances: list[str]
) -> list[types.SingleParticipantResult|None]: ) -> list[types.SingleParticipantResult|None]:
rawResults = totalResults.getById(participant.id) rawResults = totalResults.getById(participant.id)
self.l.log(5, 'Found result data (raw): %s', rawResults) self.l.log(5, 'Found result data for id %i (raw): %s', participant.id, rawResults)
results = [None for x in allDances] results = [None for x in allDances]
@ -589,7 +618,10 @@ class Worker:
keys = list(importedData.tabges.keys()) keys = list(importedData.tabges.keys())
selected = list(map(selectEntry, keys)) selected = list(map(selectEntry, keys))
try:
selectedIndex = selected.index(True) selectedIndex = selected.index(True)
except:
continue
raw = importedData.tabges[keys[selectedIndex]] raw = importedData.tabges[keys[selectedIndex]]
self.l.log(5,'Raw %s', raw) self.l.log(5,'Raw %s', raw)