123456789101112131415161718192021 |
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- from sqlalchemy.orm import Session
- from sqlalchemy import text, exists, and_, or_, not_
- from sqlalchemy.sql import func
- from database import get_db
- from extensions import logger
- import random
- from models import *
- def get_next_event_id(db: Session):
- while True:
- random_10_digit_number = random.randint(1000000000, 9999999999)
- taskId = 'task' + str(random_10_digit_number)
- it_exists = db.query(
- exists().where(TaskRegistration.task_id == taskId)
- ).scalar()
- if it_exists == False:
- return taskId
|