-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.py
94 lines (85 loc) · 3.75 KB
/
seed.py
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
import random
def seed_database():
# Import app and db here to avoid circular import issues
from app import app, db
from models import Story, Bug, Epic
# Push the app context so we can interact with the database
with app.app_context():
# Clear existing data
db.drop_all()
db.create_all()
# Create Epics
epics = [
Epic(title="Widget Factory", description="Develop a microservice-based system for automated widget production"),
Epic(title="User Authentication", description="Implement and improve a scalable, secure user authentication system"),
Epic(title="Reporting Dashboard", description="Design and build a dynamic dashboard for data reporting and visualization")
]
db.session.add_all(epics)
db.session.commit()
# Create realistic stories
stories = [
{
"title": "Integrate payment gateway with microservice architecture",
"description": "Connect the payment processing system with the widget factory microservices using REST APIs.",
"epic": epics[0]
},
{
"title": "Implement OAuth2 for third-party login",
"description": "Add OAuth2.0 integration to allow users to log in using Google and GitHub credentials.",
"epic": epics[1]
},
{
"title": "Create filter and sorting functionality for reports",
"description": "Add options for users to filter and sort reports by date, type, and status.",
"epic": epics[2]
},
{
"title": "Refactor user session management",
"description": "Improve performance by refactoring the session management system to use Redis.",
"epic": epics[1]
}
]
# Create realistic bugs
bugs = [
{
"title": "Widget production line crashes under load",
"description": "The system crashes when processing more than 1000 widgets simultaneously. Investigate memory leaks.",
"epic": epics[0]
},
{
"title": "OAuth callback URL misconfigured",
"description": "OAuth2 callback fails due to incorrect URL routing configuration in production.",
"epic": epics[1]
},
{
"title": "Dashboard charts not rendering on Safari",
"description": "Charts fail to load in the Safari browser due to compatibility issues with the charting library.",
"epic": epics[2]
},
{
"title": "Session timeout not handled gracefully",
"description": "Users are not redirected to the login page after session expiration, causing application errors.",
"epic": epics[1]
}
]
# Add stories and bugs to the database
for story_data in stories:
story = Story(
title=story_data["title"],
description=story_data["description"],
status=random.choice(['Open', 'In Progress', 'Closed']),
epic=story_data["epic"]
)
db.session.add(story)
for bug_data in bugs:
bug = Bug(
title=bug_data["title"],
description=bug_data["description"],
status=random.choice(['Open', 'In Progress', 'Closed']),
epic=bug_data["epic"]
)
db.session.add(bug)
db.session.commit() # Commit the created stories and bugs
print("Database seeded successfully!")
if __name__ == "__main__":
seed_database()