1
+ from datetime import datetime
1
2
from uuid import uuid4
2
3
3
4
from ibutsu_server .db .base import Boolean
@@ -65,38 +66,39 @@ def to_dict(self):
65
66
66
67
class Artifact (Model , FileMixin ):
67
68
__tablename__ = "artifacts"
68
- result_id = Column (PortableUUID (), ForeignKey ("results.id" ), nullable = False )
69
- filename = Column (Text )
69
+ result_id = Column (PortableUUID (), ForeignKey ("results.id" ), nullable = False , index = True )
70
+ filename = Column (Text , index = True )
70
71
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
72
+ upload_date = Column (DateTime , default = datetime .utcnow , index = True )
71
73
72
74
73
75
class Group (Model , ModelMixin ):
74
76
__tablename__ = "groups"
75
- name = Column (Text )
77
+ name = Column (Text , index = True )
76
78
projects = relationship ("Project" )
77
79
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
78
80
79
81
80
82
class Import (Model , ModelMixin ):
81
83
__tablename__ = "imports"
82
84
file = relationship ("ImportFile" )
83
- filename = Column (Text )
84
- format = Column (Text )
85
+ filename = Column (Text , index = True )
86
+ format = Column (Text , index = True )
85
87
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
86
- status = Column (Text )
88
+ status = Column (Text , index = True )
87
89
88
90
89
91
class ImportFile (Model , FileMixin ):
90
92
__tablename__ = "import_files"
91
- import_id = Column (PortableUUID (), ForeignKey ("imports.id" ), nullable = False )
93
+ import_id = Column (PortableUUID (), ForeignKey ("imports.id" ), nullable = False , index = True )
92
94
93
95
94
96
class Project (Model , ModelMixin ):
95
97
__tablename__ = "projects"
96
- name = Column (Text )
97
- title = Column (Text )
98
- owner_id = Column (Text )
99
- group_id = Column (PortableUUID (), ForeignKey ("groups.id" ))
98
+ name = Column (Text , index = True )
99
+ title = Column (Text , index = True )
100
+ owner_id = Column (Text , index = True )
101
+ group_id = Column (PortableUUID (), ForeignKey ("groups.id" ), index = True )
100
102
reports = relationship ("Report" )
101
103
results = relationship ("Result" )
102
104
runs = relationship ("Run" )
@@ -105,64 +107,64 @@ class Project(Model, ModelMixin):
105
107
106
108
class Report (Model , ModelMixin ):
107
109
__tablename__ = "reports"
108
- created = Column (DateTime )
109
- download_url = Column (Text )
110
- filename = Column (Text )
111
- mimetype = Column (Text )
112
- name = Column (Text )
110
+ created = Column (DateTime , default = datetime . utcnow , index = True )
111
+ download_url = Column (Text , index = True )
112
+ filename = Column (Text , index = True )
113
+ mimetype = Column (Text , index = True )
114
+ name = Column (Text , index = True )
113
115
params = Column (mutable_json_type (dbtype = PortableJSON ()))
114
- project_id = Column (PortableUUID (), ForeignKey ("projects.id" ))
116
+ project_id = Column (PortableUUID (), ForeignKey ("projects.id" ), index = True )
115
117
file = relationship ("ReportFile" )
116
- status = Column (Text )
117
- url = Column (Text )
118
- view_url = Column (Text )
118
+ status = Column (Text , index = True )
119
+ url = Column (Text , index = True )
120
+ view_url = Column (Text , index = True )
119
121
120
122
121
123
class ReportFile (Model , FileMixin ):
122
124
__tablename__ = "report_files"
123
- report_id = Column (PortableUUID (), ForeignKey ("reports.id" ), nullable = False )
124
- filename = Column (Text )
125
+ report_id = Column (PortableUUID (), ForeignKey ("reports.id" ), nullable = False , index = True )
126
+ filename = Column (Text , index = True )
125
127
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
126
128
127
129
128
130
class Result (Model , ModelMixin ):
129
131
__tablename__ = "results"
130
132
artifacts = relationship ("Artifact" )
131
- component = Column (Text )
133
+ component = Column (Text , index = True )
132
134
# this is metadata but it is a reserved attr
133
135
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
134
- duration = Column (Float )
135
- env = Column (Text )
136
+ duration = Column (Float , index = True )
137
+ env = Column (Text , index = True )
136
138
params = Column (mutable_json_type (dbtype = PortableJSON ()))
137
- project_id = Column (PortableUUID (), ForeignKey ("projects.id" ))
138
- result = Column (Text )
139
- run_id = Column (PortableUUID (), ForeignKey ("runs.id" ))
140
- source = Column (Text )
141
- start_time = Column (DateTime )
142
- test_id = Column (Text )
139
+ project_id = Column (PortableUUID (), ForeignKey ("projects.id" ), index = True )
140
+ result = Column (Text , index = True )
141
+ run_id = Column (PortableUUID (), ForeignKey ("runs.id" ), index = True )
142
+ source = Column (Text , index = True )
143
+ start_time = Column (DateTime , default = datetime . utcnow , index = True )
144
+ test_id = Column (Text , index = True )
143
145
144
146
145
147
class Run (Model , ModelMixin ):
146
148
__tablename__ = "runs"
147
- component = Column (Text )
148
- created = Column (DateTime )
149
+ component = Column (Text , index = True )
150
+ created = Column (DateTime , default = datetime . utcnow , index = True )
149
151
# this is metadata but it is a reserved attr
150
152
data = Column (mutable_json_type (dbtype = PortableJSON (), nested = True ))
151
- duration = Column (Float )
152
- env = Column (Text )
153
- project_id = Column (PortableUUID (), ForeignKey ("projects.id" ))
153
+ duration = Column (Float , index = True )
154
+ env = Column (Text , index = True )
155
+ project_id = Column (PortableUUID (), ForeignKey ("projects.id" ), index = True )
154
156
results = relationship ("Result" )
155
- source = Column (Text )
156
- start_time = Column (DateTime )
157
+ source = Column (Text , index = True )
158
+ start_time = Column (DateTime , default = datetime . utcnow , index = True )
157
159
summary = Column (mutable_json_type (dbtype = PortableJSON ()))
158
160
159
161
160
162
class WidgetConfig (Model , ModelMixin ):
161
163
__tablename__ = "widget_configs"
162
- navigable = Column (Boolean )
164
+ navigable = Column (Boolean , index = True )
163
165
params = Column (mutable_json_type (dbtype = PortableJSON ()))
164
- project_id = Column (PortableUUID (), ForeignKey ("projects.id" ))
165
- title = Column (Text )
166
- type = Column (Text )
167
- weight = Column (Integer )
168
- widget = Column (Text )
166
+ project_id = Column (PortableUUID (), ForeignKey ("projects.id" ), index = True )
167
+ title = Column (Text , index = True )
168
+ type = Column (Text , index = True )
169
+ weight = Column (Integer , index = True )
170
+ widget = Column (Text , index = True )
0 commit comments