-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_sample_data.py
More file actions
103 lines (93 loc) · 2.88 KB
/
add_sample_data.py
File metadata and controls
103 lines (93 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
Script to add sample data for testing
"""
from database import SessionLocal, engine, Base
from models import User, Task, TaskStage, UserRole, TaskStatus
from datetime import date, timedelta
import random
def add_sample_data():
"""
Add sample users and tasks for testing
"""
db = SessionLocal()
try:
# Create sample users
users = [
User(
name="John Doe",
email="john@example.com",
phone="1234567890",
role=UserRole.ADMIN
),
User(
name="Jane Smith",
email="jane@example.com",
phone="0987654321",
role=UserRole.CREATOR
),
User(
name="Bob Johnson",
email="bob@example.com",
phone="1122334455",
role=UserRole.CREATOR
)
]
for user in users:
db.add(user)
db.commit()
# Create sample tasks with due dates
tasks = [
Task(
lesson_id="LESSON001",
assigned_to=1,
start_date=date.today() - timedelta(days=5),
due_date=date.today() - timedelta(days=2), # Overdue
status=TaskStatus.PENDING
),
Task(
lesson_id="LESSON002",
assigned_to=2,
start_date=date.today() - timedelta(days=3),
due_date=date.today() + timedelta(days=2),
status=TaskStatus.PENDING
),
Task(
lesson_id="LESSON003",
assigned_to=3,
start_date=date.today() - timedelta(days=10),
due_date=date.today() - timedelta(days=3), # Overdue
status=TaskStatus.PENDING
)
]
for task in tasks:
db.add(task)
db.commit()
# Add stages for tasks
stages = [
"AI Image Creation",
"Image Voice-over",
"Screen Recording",
"Screen Voice-over",
"AI Audio Track",
"Video Editing"
]
for task in tasks:
for stage_name in stages:
stage = TaskStage(
task_id=task.id,
stage_name=stage_name,
stage_status="Pending"
)
db.add(stage)
db.commit()
print("Sample data added successfully!")
print(f"Added {len(users)} users")
print(f"Added {len(tasks)} tasks")
print(f"Added {len(tasks) * len(stages)} stages")
except Exception as e:
print(f"Error adding sample data: {str(e)}")
db.rollback()
finally:
db.close()
if __name__ == "__main__":
add_sample_data()