-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
252 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""GitHub app models index.""" | ||
|
||
from apps.github.index.issue import IssueIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""GitHub app models mixins.""" | ||
|
||
from apps.github.models.mixins.issue import IssueIndexMixin | ||
from apps.github.models.mixins.organization import OrganizationIndexMixin | ||
from apps.github.models.mixins.repository import RepositoryIndexMixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""GitHub organization mixins.""" | ||
|
||
from apps.common.utils import join_values | ||
|
||
|
||
class OrganizationIndexMixin: | ||
"""Organization index mixin.""" | ||
|
||
@property | ||
def idx_name(self): | ||
"""Return name for indexing.""" | ||
return join_values((self.name, self.login)) | ||
|
||
@property | ||
def idx_company(self): | ||
"""Return company for indexing.""" | ||
return join_values((self.company, self.location)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""GitHub repository mixins.""" | ||
|
||
|
||
class RepositoryIndexMixin: | ||
"""Repository index mixin.""" | ||
|
||
@property | ||
def idx_contributors_count(self): | ||
"""Return contributors count for indexing.""" | ||
return self.contributors_count | ||
|
||
@property | ||
def idx_description(self): | ||
"""Return description for indexing.""" | ||
return self.description | ||
|
||
@property | ||
def idx_forks_count(self): | ||
"""Return forks count for indexing.""" | ||
return self.forks_count | ||
|
||
@property | ||
def idx_languages(self): | ||
"""Return languages for indexing.""" | ||
return self.top_languages | ||
|
||
@property | ||
def idx_name(self): | ||
"""Return name for indexing.""" | ||
return self.name | ||
|
||
@property | ||
def idx_open_issues_count(self): | ||
"""Return open issues count for indexing.""" | ||
return self.open_issues_count | ||
|
||
@property | ||
def idx_pushed_at(self): | ||
"""Return pushed at for indexing.""" | ||
return self.pushed_at | ||
|
||
@property | ||
def idx_stars_count(self): | ||
"""Return stars count for indexing.""" | ||
return self.stars_count | ||
|
||
@property | ||
def idx_subscribers_count(self): | ||
"""Return subscribers count for indexing.""" | ||
return self.stars_count | ||
|
||
@property | ||
def idx_topics(self): | ||
"""Return topics for indexing.""" | ||
return self.topics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""OWASP app search API.""" | ||
|
||
from apps.owasp.api.search.issue import project_issues | ||
from apps.owasp.api.search.project import projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""OWASP app project search API.""" | ||
|
||
from algoliasearch_django import raw_search | ||
from django.http import JsonResponse | ||
|
||
from apps.owasp.models import Project | ||
|
||
|
||
def projects(request): | ||
"""Search projects view.""" | ||
params = { | ||
"attributesToRetrieve": [ | ||
"idx_name", | ||
"idx_topics", | ||
"idx_url", | ||
], | ||
"hitsPerPage": 25, | ||
} | ||
|
||
return JsonResponse( | ||
raw_search(Project, request.GET.get("q", ""), params)["hits"], | ||
safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""OWASP app models index.""" | ||
|
||
from apps.owasp.index.project import ProjectIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""OWASP app models mixins.""" | ||
|
||
from apps.owasp.models.mixins.project import ProjectIndexMixin |
Oops, something went wrong.