def reverse_start_time(): obj = race() handicap_start = OTime(msec=obj.get_setting('handicap_start', OTime(hour=11).to_msec())) handicap_interval = OTime(msec=obj.get_setting('handicap_interval', OTime(minute=30).to_msec())) handicap_dsg_offset = OTime( msec=obj.get_setting('handicap_dsg_offset', OTime(minute=10).to_msec())) rc = ResultCalculation(obj) for group in obj.groups: results = rc.get_group_finishes(group) # get sorted results first_group = [] second_group = [] for result in results: assert isinstance(result, Result) if result.status == ResultStatus.OK and result.person: second_group.append(result.person) # reverse main group, leader should be last second_group.reverse() persons = rc.get_group_persons(group) for person in persons: if person not in second_group: first_group.append(person) # first process DSQ and DNS - toss them first_group = DrawManager(obj).process_array(first_group, False, True, False) cur_time = handicap_start for person in first_group: assert isinstance(person, Person) person.start_time = cur_time cur_time += handicap_interval # add offset after DSQ and DNS cur_time += handicap_dsg_offset - handicap_interval # set time for main group for person in second_group: assert isinstance(person, Person) person.start_time = cur_time cur_time += handicap_interval
def handicap_start_time(): obj = race() handicap_start = OTime(msec=obj.get_setting('handicap_start', OTime(hour=11).to_msec())) handicap_max_gap = OTime(msec=obj.get_setting('handicap_max_gap', OTime(minute=30).to_msec())) handicap_second_start = OTime( msec=obj.get_setting('handicap_second_start', OTime(hour=11, minute=30).to_msec())) handicap_interval = OTime(msec=obj.get_setting('handicap_interval', OTime(minute=30).to_msec())) rc = ResultCalculation(obj) for group in obj.groups: results = rc.get_group_finishes(group) # get sorted results leader_time = rc.get_group_leader_time(group) changed_persons = [] current_second_group_time = handicap_second_start for result in results: assert isinstance(result, Result) cur_time = result.get_result_otime() gap = cur_time - leader_time if gap < handicap_max_gap and result.status == ResultStatus.OK: start_time = handicap_start + gap else: start_time = current_second_group_time current_second_group_time += handicap_interval if result.person: result.person.start_time = start_time changed_persons.append(result.person) # also process people without finish (DNS) persons = rc.get_group_persons(group) for person in persons: if person not in changed_persons: person.start_time = current_second_group_time current_second_group_time += handicap_interval