From b9d1af14572d88bbf89f96fa6f6803e742e4b894 Mon Sep 17 00:00:00 2001 From: Rushabh <145254552+Rushhaabhhh@users.noreply.github.com> Date: Wed, 29 Jan 2025 07:47:41 +0530 Subject: [PATCH] Clean up project index structure (#652) (#653) --- backend/apps/github/index/user.py | 4 -- backend/apps/owasp/index/project.py | 4 -- backend/apps/owasp/models/mixins/project.py | 58 --------------------- frontend/src/utils/paramsMapping.ts | 3 -- 4 files changed, 69 deletions(-) diff --git a/backend/apps/github/index/user.py b/backend/apps/github/index/user.py index f3f081c265..e7c24cb2fa 100644 --- a/backend/apps/github/index/user.py +++ b/backend/apps/github/index/user.py @@ -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", diff --git a/backend/apps/owasp/index/project.py b/backend/apps/owasp/index/project.py index 227c1dd304..94ace52d8e 100644 --- a/backend/apps/owasp/index/project.py +++ b/backend/apps/owasp/index/project.py @@ -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", @@ -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", diff --git a/backend/apps/owasp/models/mixins/project.py b/backend/apps/owasp/models/mixins/project.py index 99818d6e76..1b94262921 100644 --- a/backend/apps/owasp/models/mixins/project.py +++ b/backend/apps/owasp/models/mixins/project.py @@ -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.""" @@ -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.""" diff --git a/frontend/src/utils/paramsMapping.ts b/frontend/src/utils/paramsMapping.ts index d219fcefe8..88919066f7 100644 --- a/frontend/src/utils/paramsMapping.ts +++ b/frontend/src/utils/paramsMapping.ts @@ -46,8 +46,6 @@ 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', @@ -55,7 +53,6 @@ export const getParamsForIndexName = (indexName: string, distinct = false) => { 'idx_level', 'idx_name', 'idx_organizations', - 'idx_releases', 'idx_repositories', 'idx_repositories_count', 'idx_stars_count',