""" """ from sqlalchemy import select from datetime import datetime, timedelta from app.core import config from app.core.session import session from app.models import Sms, Project TEST_SMS_PROJECT_NAME = "test_project pour sms" NUMBER_OF_SMS = 80 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.name == TEST_SMS_PROJECT_NAME)) project = result.scalars().first() if project is None: project = Project(name=TEST_SMS_PROJECT_NAME, is_public=False) db.add(project) db.commit() db.refresh(project) now = datetime.now() for t in range(NUMBER_OF_SMS): sending_time = now + timedelta(minutes=t * 45) 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()