2022-06-07 19:27:13 +02:00
|
|
|
from flask.cli import with_appcontext
|
|
|
|
from click import command
|
|
|
|
|
|
|
|
from ..dependencies import db
|
2022-11-12 16:18:07 +01:00
|
|
|
# from ..factory import ProjectSupervisorFactory, GroupFactory, StudentFactory
|
2022-06-07 19:27:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
@command('init_db')
|
|
|
|
@with_appcontext
|
|
|
|
def init_db() -> None:
|
|
|
|
"""Fill database with some data"""
|
|
|
|
db.drop_all()
|
|
|
|
db.create_all()
|
2022-11-12 16:18:07 +01:00
|
|
|
#
|
|
|
|
# num_of_supervisors = 5
|
|
|
|
#
|
|
|
|
# projects_supervisors = [ProjectSupervisorFactory() for _ in range(num_of_supervisors)]
|
|
|
|
# db.session.add_all(projects_supervisors)
|
|
|
|
# db.session.commit()
|
|
|
|
#
|
|
|
|
# groups = [GroupFactory(project_supervisor=projects_supervisors[i]) for i in range(num_of_supervisors)]
|
|
|
|
# db.session.add_all(groups)
|
|
|
|
# db.session.commit()
|
|
|
|
#
|
|
|
|
# num_of_students = num_of_supervisors * 3
|
|
|
|
# students = [StudentFactory(group=groups[i % num_of_supervisors]) for i in range(num_of_students)]
|
|
|
|
#
|
|
|
|
# max_count = 10
|
|
|
|
# max_length = len(students)
|
|
|
|
# start_count = 0
|
|
|
|
#
|
|
|
|
# while True:
|
|
|
|
# if start_count > max_length:
|
|
|
|
# break
|
|
|
|
# db.session.add_all(students[start_count:max_count])
|
|
|
|
# db.session.commit()
|
|
|
|
# start_count += max_count
|