def get_raw_results_for_update(self, user): ext_input = download_from_ext_input(self.url, self.raw_data_file) if ext_input: self.name = ext_input['name'] self.serie = ext_input['serie'] self.begin = aware_datetime(ext_input['begin']) self.uploaded_by = user self.upload_time = timezone.now() if 'uuid' in ext_input and ext_input['uuid']: self.opt_uuid = ext_input['uuid'] self.save() return ext_input
def create_result(extended_dict, course): rnnr = get_matching_runner(extended_dict['name']) # None if no match if extended_dict['starttime']: start_time = aware_datetime(extended_dict['starttime']) else: start_time = None if extended_dict['readtime']: read_time = aware_datetime(extended_dict['readtime']) else: read_time = None rs = Result(course=course, runner=rnnr, start_time=start_time, read_time=read_time) for key, value in extended_dict.items(): if hasattr(rs, key) and key not in ['id', 'course']: setattr(rs, key, value) # Added by Riku on 2020-10-09 if rs.time == LONGTIME: rs.time = None rs.save() return rs
def match_obj_fields_to_dict(self, res_dict, *args): # *args are in the function signature, the dpbasemanager call to # to this function carries the cc_list, but it is not used here self.runner = MatchName.matchnames.get_matching_runner( res_dict['name']) # None if no match if res_dict['starttime']: self.start_time = aware_datetime(res_dict['starttime']) else: self.start_time = None if res_dict['readtime']: self.read_time = aware_datetime(res_dict['readtime']) else: self.read_time = None for key, value in res_dict.items(): if hasattr(self, key) and key not in [ 'id', 'start_time', 'read_time', 'course' ]: setattr(self, key, value) # Added by Riku on 2020-10-09 if self.time == LONGTIME: self.time = None
def create_race(self, form_data, user): ext_input = form_data['ext_input'] url = form_data['url'] if 'url' in form_data else "" f = form_data['file'] if 'file' in form_data else None r = self.model(name=ext_input['name'], url=url, serie=ext_input['serie'], begin=aware_datetime(ext_input['begin']), raw_data_file=f, upload_time=timezone.now(), uploaded_by=user) if 'uuid' in ext_input and ext_input['uuid']: r.opt_uuid = ext_input['uuid'] r.save() return r
def can_be_added(self, ext_input): input_begin = aware_datetime(ext_input['begin']) n = self.filter(name=ext_input['name'], serie=ext_input['serie'], begin=input_begin).count() return n == 0
def get_time_from_timestamps(result): start_str = get_standard_dt(result['registerTime']) start = aware_datetime(start_str) end_str = get_standard_dt(result['readTime']) end = aware_datetime(end_str) return int((end - start).total_seconds())
def match_obj_fields_to_dict(self, course_dict): self.begin = aware_datetime(course_dict['begin']) for key, value in course_dict.items(): if hasattr(self, key) and key not in ['id', 'race', 'begin']: setattr(self, key, value)