def archive(call: APICall, company_id, request: ArchiveRequest): archived = 0 tasks = TaskBLL.assert_exists( company_id, task_ids=request.tasks, only=("id", "execution", "status", "project", "system_tags"), ) for task in tasks: try: TaskBLL.dequeue_and_change_status( task, company_id, request.status_message, request.status_reason, ) except APIError: # dequeue may fail if the task was not enqueued pass task.update( status_message=request.status_message, status_reason=request.status_reason, system_tags=sorted( set(task.system_tags) | {EntityVisibility.archived.value} ), last_change=datetime.utcnow(), ) archived += 1 call.result.data_model = ArchiveResponse(archived=archived)
def archive(call: APICall, company_id, request: ArchiveRequest): tasks = TaskBLL.assert_exists( company_id, task_ids=request.tasks, only=("id", "execution", "status", "project", "system_tags", "enqueue_status"), ) archived = 0 for task in tasks: archived += archive_task( company_id=company_id, task=task, status_message=request.status_message, status_reason=request.status_reason, ) call.result.data_model = ArchiveResponse(archived=archived)