def add(self, element: AssignationProxy) -> None: compatible_list = [] for deleted_element in self.to_be_deleted: intersect = AssignationOperator.are_intersection( element, deleted_element) are_compatible = AssignationOperator.are_compatible( element, deleted_element) if intersect and are_compatible: compatible_list.append(deleted_element) best = AssignationOperator.get_biggest_assign(compatible_list) if best: best.range_obj = element.range_obj best.starting_day = element.starting_day self.to_be_deleted.remove(best) if best.has_change(): self.to_be_updated.append(best) hash_key = self.hash_function(best) if hash_key not in self.db: self.db[hash_key] = [] self.db[hash_key].append(best) else: super().add(element)
def clean_updated_assign(self, assign: AssignationProxy, assigns: List[AssignationProxy]) -> None: if hasattr(assign, 'was_deleted'): was_deleted = assign.was_deleted else: differences = assign.get_differences() was_deleted = differences['was_deleted'] for aux_assign in assigns: are_compatible = AssignationOperator.are_compatible( assign, aux_assign) if assign != aux_assign and are_compatible: for del_range in was_deleted: intersection = RangeOperator.get_intersection( del_range, aux_assign.range_obj) del_range, new_range = del_range - intersection if new_range: was_deleted.append(new_range) if aux_assign.is_in_real_db(): ranges = self.remove_range_on_created_range( intersection, aux_assign) aux_assign.was_created = ranges else: ranges = self.remove_range_on_new_assign( intersection, aux_assign) aux_assign.was_created = ranges assign.was_deleted = was_deleted