Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @router.post(
- "/worker/cancel_backup_task",
- summary="cancel booked task by worker.This doesnt store time stamp operation"
- )
- async def cancel_backup_task(
- user: dict = Depends(worker_resolver),
- task: dict = Depends(in_progress_task_resolver)
- ):
- await MONGO_CLIENT.in_progress_tasks.delete(task['_id'])
- await collect_time_stamp_for_customer('in_progress_tasks_deletion_time_stamp', user, task)
- await MONGO_CLIENT.pending_tasks.pull({'_id': user['_id'], 'tasks': task})
- await MONGO_CLIENT.pending_tasks.pull({'_id': task['customer_id'], 'tasks': task})
- time_left_to_start_task_in_hours = ((task['task_details'][
- 'start'] - datetime.datetime.now()).total_seconds()) / 3600
- if time_left_to_start_task_in_hours >= 1:
- await MONGO_CLIENT.instant_tasks.insert(task)
- return JSONResponse({
- 'code': 1,
- 'content': {'message': "Moved to Instant Tasks"}
- })
- else:
- # Do refund
- await MONGO_CLIENT.cancelled_tasks.insert(task)
- return JSONResponse({
- 'code': 1,
- 'content': {'message': "Backup Task has been Cancelled"}
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement