Add a RepositoryActionCount table so we can use it (instead of LogEntry) when scoring repo search results
This commit is contained in:
parent
703f48f194
commit
3f1e8f3c27
8 changed files with 137 additions and 19 deletions
|
@ -299,7 +299,7 @@ class Repository(BaseModel):
|
|||
# Therefore, we define our own deletion order here and use the dependency system to verify it.
|
||||
ordered_dependencies = [RepositoryAuthorizedEmail, RepositoryTag, Image, LogEntry,
|
||||
RepositoryBuild, RepositoryBuildTrigger, RepositoryNotification,
|
||||
RepositoryPermission, AccessToken, Star]
|
||||
RepositoryPermission, AccessToken, Star, RepositoryActionCount]
|
||||
|
||||
for query, fk in self.dependencies(search_nullable=True):
|
||||
model = fk.model_class
|
||||
|
@ -560,6 +560,20 @@ class LogEntry(BaseModel):
|
|||
metadata_json = TextField(default='{}')
|
||||
|
||||
|
||||
class RepositoryActionCount(BaseModel):
|
||||
repository = ForeignKeyField(Repository, index=True)
|
||||
count = IntegerField()
|
||||
date = DateField(index=True)
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
read_slaves = (read_slave,)
|
||||
indexes = (
|
||||
# create a unique index on repository and date
|
||||
(('repository', 'date'), True),
|
||||
)
|
||||
|
||||
|
||||
class OAuthApplication(BaseModel):
|
||||
client_id = CharField(index=True, default=random_string_generator(length=20))
|
||||
client_secret = CharField(default=random_string_generator(length=40))
|
||||
|
@ -645,4 +659,4 @@ all_models = [User, Repository, Image, AccessToken, Role, RepositoryPermission,
|
|||
ExternalNotificationEvent, ExternalNotificationMethod, RepositoryNotification,
|
||||
RepositoryAuthorizedEmail, ImageStorageTransformation, DerivedImageStorage,
|
||||
TeamMemberInvite, ImageStorageSignature, ImageStorageSignatureKind,
|
||||
AccessTokenKind, Star]
|
||||
AccessTokenKind, Star, RepositoryActionCount]
|
||||
|
|
Reference in a new issue