-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmodels.py
More file actions
249 lines (203 loc) · 7.65 KB
/
models.py
File metadata and controls
249 lines (203 loc) · 7.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
"""
Models per docs/Schema.md section 3: Boost Library Tracker.
Extends github_activity_tracker (GitHubRepository, GitHubFile) and references
cppa_user_tracker.GitHubAccount.
"""
from django.db import models
from github_activity_tracker.models import GitHubRepository
# --- Part 1: Boost Library, Headers, and Dependencies ---
class BoostLibraryRepository(GitHubRepository):
"""Extends GitHubRepository with boost-library-specific fields (multi-table inheritance)."""
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "boost_library_tracker_boostlibraryrepository"
ordering = ["repo_name"]
class BoostLibrary(models.Model):
"""Boost library within a BoostLibraryRepository."""
repo = models.ForeignKey(
BoostLibraryRepository,
on_delete=models.CASCADE,
related_name="libraries",
db_column="repo_id",
)
name = models.CharField(max_length=255, db_index=True)
class Meta:
db_table = "boost_library_tracker_boostlibrary"
ordering = ["repo", "name"]
constraints = [
models.UniqueConstraint(
fields=["repo", "name"],
name="boost_library_tracker_repo_name_uniq",
)
]
class BoostFile(models.Model):
"""Extends GitHubFile with library association (1:1 to GitHubFile)."""
github_file = models.OneToOneField(
"github_activity_tracker.GitHubFile",
on_delete=models.CASCADE,
primary_key=True,
related_name="boost_file",
db_column="github_file_id",
)
library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="files",
db_column="library_id",
)
class Meta:
db_table = "boost_library_tracker_boostfile"
class BoostVersion(models.Model):
"""Boost release version (e.g. 1.81.0)."""
version = models.CharField(max_length=64, unique=True, db_index=True)
version_created_at = models.DateTimeField(null=True, blank=True)
class Meta:
db_table = "boost_library_tracker_boostversion"
ordering = ["-version_created_at", "version"]
class BoostLibraryVersion(models.Model):
"""Library version for a given Boost release."""
library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="library_versions",
db_column="library_id",
)
version = models.ForeignKey(
BoostVersion,
on_delete=models.CASCADE,
related_name="library_versions",
db_column="version_id",
)
cpp_version = models.CharField(max_length=64, blank=True)
description = models.TextField(blank=True)
key = models.CharField(max_length=255, blank=True, db_index=True)
documentation = models.CharField(max_length=255, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "boost_library_tracker_boostlibraryversion"
ordering = ["library", "version"]
constraints = [
models.UniqueConstraint(
fields=["library", "version"],
name="boost_library_tracker_lib_version_uniq",
)
]
class BoostDependency(models.Model):
"""Dependency: client_library depends on dep_library for a given Boost version."""
client_library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="dependencies_as_client",
db_column="client_library_id",
)
version = models.ForeignKey(
BoostVersion,
on_delete=models.CASCADE,
related_name="dependencies",
db_column="version_id",
)
dep_library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="dependencies_as_dep",
db_column="dep_library_id",
)
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = "boost_library_tracker_boostdependency"
ordering = ["client_library", "version", "dep_library"]
constraints = [
models.UniqueConstraint(
fields=["client_library", "version", "dep_library"],
name="boost_library_tracker_dep_uniq",
)
]
class DependencyChangeLog(models.Model):
"""Log of dependency add/remove for a client/dep library pair."""
client_library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="dependency_changelog_as_client",
db_column="client_library_id",
)
dep_library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="dependency_changelog_as_dep",
db_column="dep_library_id",
)
is_add = models.BooleanField()
created_at = models.DateField(db_index=True)
class Meta:
db_table = "boost_library_tracker_dependencychangelog"
ordering = ["-created_at", "client_library", "dep_library"]
constraints = [
models.UniqueConstraint(
fields=["client_library", "dep_library", "created_at"],
name="boost_library_tracker_changelog_uniq",
)
]
# --- Part 2: Maintainers, Authors, and Categories ---
class BoostLibraryCategory(models.Model):
"""Category label for libraries (e.g. Math, Container)."""
name = models.CharField(max_length=255, unique=True, db_index=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "boost_library_tracker_boostlibrarycategory"
ordering = ["name"]
verbose_name_plural = "Boost library categories"
class BoostLibraryRoleRelationship(models.Model):
"""Maintainer/author of a library version (links GitHubAccount to BoostLibraryVersion)."""
library_version = models.ForeignKey(
BoostLibraryVersion,
on_delete=models.CASCADE,
related_name="role_relationships",
db_column="library_version_id",
)
account = models.ForeignKey(
"cppa_user_tracker.GitHubAccount",
on_delete=models.CASCADE,
related_name="boost_library_roles",
db_column="account_id",
)
is_maintainer = models.BooleanField(default=False)
is_author = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "boost_library_tracker_boostlibraryrolerelationship"
ordering = ["library_version", "account"]
constraints = [
models.UniqueConstraint(
fields=["library_version", "account"],
name="boost_library_tracker_role_uniq",
)
]
class BoostLibraryCategoryRelationship(models.Model):
"""Library–category link."""
library = models.ForeignKey(
BoostLibrary,
on_delete=models.CASCADE,
related_name="category_relationships",
db_column="library_id",
)
category = models.ForeignKey(
BoostLibraryCategory,
on_delete=models.CASCADE,
related_name="library_relationships",
db_column="category_id",
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "boost_library_tracker_boostlibrarycategoryrelationship"
ordering = ["library", "category"]
constraints = [
models.UniqueConstraint(
fields=["library", "category"],
name="boost_library_tracker_lib_cat_uniq",
)
]