def populate_database(): """Populate database with fake data.""" click.echo("Creating 5 users") usernames = [] for _ in tqdm(range(5)): usernames.append(UserFactory.create().username) db.session.commit() click.echo("Creating 50 participants") for _ in tqdm(range(50)): ParticipantFactory.create() db.session.commit() click.echo("Creating 30 hacknights") all_participants = Participant.query.all() for _ in tqdm(range(30)): HacknightFactory.create(participants=random.sample( all_participants, random.randint(5, 30))) db.session.commit() click.echo("Creating 5 teams") for _ in tqdm(range(5)): TeamFactory.create( members=random.sample(all_participants, random.randint(1, 40))) db.session.commit() click.echo("Created users:") for id, username in enumerate(usernames, start=1): click.echo(f"{id}. {username}")
def add_participants_to_hacknight(app, _db): HacknightFactory(participants=ParticipantFactory.create_batch(10)) _db.session.commit()
def add_hacknights(app, _db): for _ in range(10): HacknightFactory.create() _db.session.commit()