-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added * fixed linting * made changes in model * Update backend/apps/github/index/user.py Co-authored-by: Arkadii Yakovets <[email protected]> * Update code * Add key attribute --------- Co-authored-by: Arkadii Yakovets <[email protected]> Co-authored-by: Arkadii Yakovets <[email protected]>
- Loading branch information
1 parent
1d3f3d3
commit e160832
Showing
5 changed files
with
163 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""GitHub app models index.""" | ||
|
||
from apps.github.index.issue import IssueIndex | ||
from apps.github.index.user import UserIndex |
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,66 @@ | ||
"""GitHub user Algolia index configuration.""" | ||
|
||
from algoliasearch_django import AlgoliaIndex | ||
from algoliasearch_django.decorators import register | ||
|
||
from apps.common.index import IndexBase | ||
from apps.github.models.user import User | ||
|
||
|
||
@register(User) | ||
class UserIndex(AlgoliaIndex, IndexBase): | ||
"""User index.""" | ||
|
||
index_name = "users" | ||
|
||
fields = ( | ||
"idx_avatar_url", | ||
"idx_bio", | ||
"idx_company", | ||
"idx_created_at", | ||
"idx_email", | ||
"idx_followers_count", | ||
"idx_following_count", | ||
"idx_key", | ||
"idx_location", | ||
"idx_login", | ||
"idx_name", | ||
"idx_public_repositories_count", | ||
"idx_title", | ||
"idx_updated_at", | ||
"idx_url", | ||
) | ||
|
||
settings = { | ||
"attributeForDistinct": "idx_login", | ||
"minProximity": 4, | ||
"customRanking": [ | ||
"desc(idx_followers_count)", | ||
"desc(idx_created_at)", | ||
], | ||
"ranking": [ | ||
"typo", | ||
"words", | ||
"filters", | ||
"proximity", | ||
"attribute", | ||
"exact", | ||
"custom", | ||
], | ||
"searchableAttributes": [ | ||
"unordered(idx_email, idx_login, idx_name)", | ||
"unordered(idx_company, idx_location)", | ||
"unordered(idx_bio)", | ||
], | ||
} | ||
|
||
should_index = "is_indexable" | ||
|
||
def get_queryset(self): | ||
"""Get queryset for indexing.""" | ||
return User.objects.all() | ||
|
||
@staticmethod | ||
def update_synonyms(): | ||
"""Update synonyms.""" | ||
UserIndex.reindex_synonyms("github", "users") |
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,80 @@ | ||
"""GitHub user model mixins for index-related functionality.""" | ||
|
||
|
||
class UserIndexMixin: | ||
"""User index mixin.""" | ||
|
||
@property | ||
def idx_avatar_url(self): | ||
"""Return avatar URL for indexing.""" | ||
return self.avatar_url | ||
|
||
@property | ||
def idx_bio(self): | ||
"""Return bio for indexing.""" | ||
return self.bio | ||
|
||
@property | ||
def idx_company(self): | ||
"""Return company for indexing.""" | ||
return self.company | ||
|
||
@property | ||
def idx_created_at(self): | ||
"""Return created at timestamp for indexing.""" | ||
return self.created_at | ||
|
||
@property | ||
def idx_email(self): | ||
"""Return email for indexing.""" | ||
return self.email | ||
|
||
@property | ||
def idx_key(self): | ||
"""Return key for indexing.""" | ||
return self.login | ||
|
||
@property | ||
def idx_followers_count(self): | ||
"""Return followers count for indexing.""" | ||
return self.followers_count | ||
|
||
@property | ||
def idx_following_count(self): | ||
"""Return following count for indexing.""" | ||
return self.following_count | ||
|
||
@property | ||
def idx_location(self): | ||
"""Return location for indexing.""" | ||
return self.location | ||
|
||
@property | ||
def idx_login(self): | ||
"""Return login for indexing.""" | ||
return self.login | ||
|
||
@property | ||
def idx_name(self): | ||
"""Return name for indexing.""" | ||
return self.name | ||
|
||
@property | ||
def idx_public_repositories_count(self): | ||
"""Return public repositories count for indexing.""" | ||
return self.public_repositories_count | ||
|
||
@property | ||
def idx_title(self): | ||
"""Return title for indexing.""" | ||
return self.title | ||
|
||
@property | ||
def idx_updated_at(self): | ||
"""Return updated at timestamp for indexing.""" | ||
return self.updated_at | ||
|
||
@property | ||
def idx_url(self): | ||
"""Return GitHub profile URL for indexing.""" | ||
return self.url |
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