Skip to content

Commit

Permalink
Clean up project index structure (OWASP#652) (OWASP#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushhaabhhh authored Jan 29, 2025
1 parent f00f251 commit b9d1af1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 69 deletions.
4 changes: 0 additions & 4 deletions backend/apps/github/index/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ class UserIndex(AlgoliaIndex, IndexBase):
"idx_email",
"idx_followers_count",
"idx_following_count",
"idx_issues_count",
"idx_issues",
"idx_key",
"idx_location",
"idx_login",
"idx_name",
"idx_public_repositories_count",
"idx_releases_count",
"idx_releases",
"idx_title",
"idx_updated_at",
"idx_url",
Expand Down
4 changes: 0 additions & 4 deletions backend/apps/owasp/index/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class ProjectIndex(AlgoliaIndex, IndexBase):
"idx_custom_tags",
"idx_description",
"idx_forks_count",
"idx_issues",
"idx_issues_count",
"idx_is_active",
"idx_key",
"idx_languages",
Expand All @@ -30,8 +28,6 @@ class ProjectIndex(AlgoliaIndex, IndexBase):
"idx_level",
"idx_name",
"idx_organizations",
"idx_releases",
"idx_releases_count",
"idx_repositories",
"idx_repositories_count",
"idx_stars_count",
Expand Down
58 changes: 0 additions & 58 deletions backend/apps/owasp/models/mixins/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,6 @@ def idx_forks_count(self):
"""Return forks count for indexing."""
return self.forks_count

@property
def idx_issues(self):
"""Return issues for indexing."""
return [
{
"author": {
"avatar_url": i.author.avatar_url if i.author else "",
"key": i.author.login if i.author else "",
"name": i.author.name if i.author else "",
},
"created_at": i.created_at.timestamp(),
"comments_count": i.comments_count,
"number": i.number,
"repository": {
"key": i.repository.key,
"owner_key": i.repository.owner.login,
},
"title": i.title,
}
for i in self.open_issues.select_related("author").order_by("-created_at")[
:ISSUES_LIMIT
]
]

@property
def idx_issues_count(self):
"""Return issues count for indexing."""
return self.open_issues.count()

@property
def idx_is_active(self):
"""Return active status for indexing."""
Expand Down Expand Up @@ -95,35 +66,6 @@ def idx_organizations(self):
"""Return organizations for indexing."""
return join_values(fields=(o.name for o in self.organizations.all()))

@property
def idx_releases(self):
"""Return releases for indexing."""
return [
{
"author": {
"avatar_url": r.author.avatar_url if r.author else "",
"key": r.author.login if r.author else "",
"name": r.author.name if r.author else "",
},
"is_pre_release": r.is_pre_release,
"name": r.name,
"published_at": r.published_at.timestamp(),
"repository": {
"key": r.repository.key,
"owner_key": r.repository.owner.login,
},
"tag_name": r.tag_name,
}
for r in self.published_releases.select_related("author").order_by("-published_at")[
:RELEASES_LIMIT
]
]

@property
def idx_releases_count(self):
"""Return releases count for indexing."""
return self.published_releases.count()

@property
def idx_repositories(self):
"""Return repositories for indexing."""
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/utils/paramsMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,13 @@ export const getParamsForIndexName = (indexName: string, distinct = false) => {
attributesToRetrieve: [
'idx_contributors_count',
'idx_forks_count',
'idx_issues',
'idx_issues_count',
'idx_is_active',
'idx_key',
'idx_languages',
'idx_leaders',
'idx_level',
'idx_name',
'idx_organizations',
'idx_releases',
'idx_repositories',
'idx_repositories_count',
'idx_stars_count',
Expand Down

0 comments on commit b9d1af1

Please # to comment.