Fiksa pdf resultatliste
This commit is contained in:
parent
275f4b0f78
commit
8621e07dcf
@ -127,8 +127,6 @@ class Runner:
|
||||
'fee_id': self.fee_id
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CardDump:
|
||||
def __init__(self, card, controls, splits, read_time, s_time, f_time):
|
||||
self.card = card
|
||||
@ -262,7 +260,7 @@ class OClass:
|
||||
|
||||
class RunnerResult:
|
||||
def __init__(self, runner_id: int, first: str, last: str, status: str, place: int, total_time: int, split_times: list[int], end_time,
|
||||
club=None, club_id=None, country=None, card_id=None, o_class=None, fork=0, start_time=None, fee_id=None):
|
||||
club=None, club_id=None, country=None, card_id=None, o_class=None, controls=None, fork=0, start_time=None, fee_id=None):
|
||||
self.id = runner_id
|
||||
self.first = first
|
||||
self.last = last
|
||||
@ -270,6 +268,7 @@ class RunnerResult:
|
||||
self.country = country
|
||||
self.card_id = card_id
|
||||
self.o_class = o_class
|
||||
self.controls = controls
|
||||
self.fork = fork
|
||||
self.start_time = start_time
|
||||
self.fee_id = fee_id
|
||||
@ -280,11 +279,14 @@ class RunnerResult:
|
||||
self.split_times = split_times
|
||||
self.end_time = end_time
|
||||
|
||||
def fullname(self):
|
||||
return f'{self.first} {self.last}'
|
||||
|
||||
class ClassResult:
|
||||
def __init__(self, name: str, course: Course, runner_results: list[RunnerResult]):
|
||||
self.name
|
||||
self.course
|
||||
self.runner_results
|
||||
self.name = name
|
||||
self.course = course
|
||||
self.runner_results = runner_results
|
||||
|
||||
class Event:
|
||||
def __init__(self, eventid, name, start_time=None, end_time=None,
|
||||
@ -351,6 +353,9 @@ class Event:
|
||||
def get_runner_time(self, id):
|
||||
runner = self.get_runner(id)
|
||||
card_dump = self.get_card_dump(runner.card_id)
|
||||
if card_dump == None:
|
||||
return False
|
||||
|
||||
f_control = card_dump.controls[-1]
|
||||
# TODO: Må gjøres mer robust
|
||||
try:
|
||||
@ -360,10 +365,22 @@ class Event:
|
||||
return False
|
||||
|
||||
def get_runner_splits(self, id):
|
||||
return self.get_card_dump(self.get_runner(id).card_id).splits
|
||||
try:
|
||||
return self.get_card_dump(self.get_runner(id).card_id).splits
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def get_runner_controls(self, id):
|
||||
try:
|
||||
return self.get_card_dump(self.get_runner(id).card_id).controls
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def get_runner_end_clock(self, id):
|
||||
return self.get_card_dump(self.get_runner(id).card_id).f_time
|
||||
try:
|
||||
return self.get_card_dump(self.get_runner(id).card_id).f_time
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
def get_result(self, o_classes: list[str] = []) -> list[ClassResult]:
|
||||
if not o_classes:
|
||||
@ -530,12 +547,18 @@ def produce_class_result(event, o_class_name) -> ClassResult:
|
||||
o_class = event.get_o_class(o_class_name)
|
||||
runners = event.get_runners_in_o_class(o_class_name)
|
||||
ok_runners = [i for i in runners if event.get_runner_status(i.id) == 'OK']
|
||||
ok_runners.sort(key=lambda i: event.get_runner_time(i.id))
|
||||
dsq_runners = [i for i in runners if event.get_runner_status(i.id) == 'MissingPunch' or event.get_runner_status(i.id) == 'Disqualified']
|
||||
other_runners = [i for i in runners if i not in ok_runners or i not in dsq_runners]
|
||||
results = [RunnerResult(i.id, i.first, i.last, 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||
event.get_runner_end_clock(i.id), i.club
|
||||
) for i in ok_runners]
|
||||
return results
|
||||
other_runners = [i for i in runners if i not in ok_runners and i not in dsq_runners]
|
||||
|
||||
results = [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), ok_runners.index(i)+1, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in ok_runners]
|
||||
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in dsq_runners]
|
||||
results += [RunnerResult(i.id, i.first, i.last, event.get_runner_status(i.id), 0, event.get_runner_time(i.id), event.get_runner_splits(i.id),
|
||||
event.get_runner_end_clock(i.id), i.club, i.country, i.card_id, i.o_class, event.get_runner_controls(i.id)) for i in other_runners]
|
||||
|
||||
return ClassResult(o_class.name, o_class.course, results)
|
||||
|
||||
# TODO: Take string instead of file.
|
||||
def courses_from_ttime_conf(ttime_file):
|
||||
|
0
test_files/sc3_23/lenker.txt
Normal file
0
test_files/sc3_23/lenker.txt
Normal file
@ -1,15 +1,16 @@
|
||||
import sys
|
||||
sys.path.insert(0, '../../otime')
|
||||
import otime
|
||||
import pdf
|
||||
|
||||
def main():
|
||||
event = otime.Event(0, 'TEEEST', start_time=None, end_time=None,organiser='Tygbe')
|
||||
event.read_ttime_cnf('tt.cnf')
|
||||
event.read_ttime_db('db.csv')
|
||||
event.read_mtr_file('mtr.csv')
|
||||
print(event.get_runner_status('28130'))
|
||||
print(event.get_result())
|
||||
event.create_start_list_pdf('output/result.pdf')
|
||||
pdf.create_result_list(event, 'output/result.pdf')
|
||||
print(event.get_runner_status('1400'))
|
||||
results = event.get_result()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user