""" """ from sqlalchemy import select from datetime import datetime, timedelta from app.core import config, security from app.core.session import session from app.models import User, Sms, Project TEST_SMS_PROJECT_NAME = "test_project pour sms" NUMBER_OF_SMS = 100 def main() -> None: print("Create SMS ") with session() as db: # Get or create the project hosting the sms result = db.execute(select(Project).where(Project.email == TEST_SMS_PROJECT_NAME)) project = result.scalars().first() if project is None: project = Project(name=TEST_SMS_PROJECT_NAME) db.add(new_superuser) db.commit() db.refresh(project) now = datetime.now() for t in range(NUMBER_OF_SMS): sending_time = now + timedelta(minutes=t * 5) sms = Sms( project_id=project.id, content=sending_time.strftime("%m/%d/%Y, %H:%M:%S"), phone_number=config.settings.BATCH_SMS_PHONE_NUMBER, sending_time=sending_time, ) db.add(sms) db.commit() if __name__ == "__main__": main()