-
-
Notifications
You must be signed in to change notification settings - Fork 105
implement real time suggestion #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
69cb115
implement real time suggestion
Rajgupta36 871905f
optimization and css changes
Rajgupta36 1b4c443
pre_commit
Rajgupta36 6253fc4
added jest config
Rajgupta36 f4fcb53
updated jest config
Rajgupta36 b0a1719
Add env-file
arkid15r fe17939
updated test case
Rajgupta36 c998e0c
updated indexName for suggestions
Rajgupta36 bd418ad
fix lint
Rajgupta36 aac7e4b
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 1b0a696
updated
Rajgupta36 b007c09
fixes
Rajgupta36 cac9e15
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 ab14a08
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 5f6cd78
fixes
Rajgupta36 39b3cf7
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 72acf5c
update var
Rajgupta36 0a46784
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 43f0f12
added_suggestion_index
Rajgupta36 ffbf926
pre-commit
Rajgupta36 ae44f85
optimization
Rajgupta36 70d285c
pre-commit
Rajgupta36 80489d1
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 a9987a7
Update code
arkid15r cd7ae7f
Update code
arkid15r 249d024
added test case for algolia_update_suggestion
Rajgupta36 d26344a
Merge branch 'main' into AutocompleteSearchBar
Rajgupta36 287c3a8
add index for users
Rajgupta36 558f606
fixes
Rajgupta36 f3eb782
Update frontend/__tests__/src/pages/Chapters.test.tsx
arkid15r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
105 changes: 105 additions & 0 deletions
105
backend/apps/common/management/commands/algolia_update_suggestions.py
This file contains hidden or 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,105 @@ | ||
"""A command to update OWASP Nest suggestions index.""" | ||
|
||
from algoliasearch.query_suggestions.client import QuerySuggestionsClientSync | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Create query suggestions for Algolia indices" | ||
|
||
def handle(self, *args, **kwargs): | ||
client = QuerySuggestionsClientSync( | ||
settings.ALGOLIA_APPLICATION_ID, | ||
settings.ALGOLIA_WRITE_API_KEY, | ||
settings.ALGOLIA_APPLICATION_REGION, | ||
) | ||
|
||
entity_configs = { | ||
"chapters": { | ||
"facets": [ | ||
{"attribute": "idx_key"}, | ||
{"attribute": "idx_name"}, | ||
{"attribute": "idx_tags"}, | ||
{"attribute": "idx_country"}, | ||
{"attribute": "idx_region"}, | ||
{"attribute": "idx_suggested_location"}, | ||
], | ||
"generate": [ | ||
["idx_name"], | ||
["idx_tags"], | ||
["idx_country"], | ||
["idx_region"], | ||
["idx_suggested_location"], | ||
], | ||
}, | ||
"committees": { | ||
"facets": [ | ||
{"attribute": "idx_key"}, | ||
{"attribute": "idx_name"}, | ||
{"attribute": "idx_tags"}, | ||
], | ||
"generate": [ | ||
["idx_name"], | ||
["idx_tags"], | ||
], | ||
}, | ||
"issues": { | ||
"facets": [ | ||
{"attribute": "idx_title"}, | ||
{"attribute": "idx_project_name"}, | ||
{"attribute": "idx_repository_name"}, | ||
{"attribute": "idx_project_tags"}, | ||
{"attribute": "idx_repository_topics"}, | ||
], | ||
"generate": [ | ||
["idx_title"], | ||
["idx_project_name"], | ||
["idx_repository_name"], | ||
["idx_project_tags"], | ||
["idx_repository_topics"], | ||
], | ||
}, | ||
"projects": { | ||
"facets": [ | ||
{"attribute": "idx_key"}, | ||
{"attribute": "idx_name"}, | ||
{"attribute": "idx_repository_names"}, | ||
{"attribute": "idx_tags"}, | ||
], | ||
"generate": [ | ||
["idx_name"], | ||
["idx_tags"], | ||
["idx_repository_names"], | ||
], | ||
}, | ||
"users": { | ||
"facets": [ | ||
{"attribute": "idx_key"}, | ||
{"attribute": "idx_name"}, | ||
{"attribute": "idx_title"}, | ||
], | ||
"generate": [ | ||
["idx_name"], | ||
["idx_title"], | ||
], | ||
}, | ||
} | ||
|
||
for entity, suggestion_settings in entity_configs.items(): | ||
source_index_name = f"{settings.ENVIRONMENT.lower()}_{entity}" | ||
suggestions_index_name = f"{settings.ENVIRONMENT.lower()}_{entity}_suggestions" | ||
|
||
configuration = { | ||
"sourceIndices": [ | ||
{ | ||
"indexName": source_index_name, | ||
**suggestion_settings, | ||
} | ||
] | ||
} | ||
client.update_config( | ||
index_name=suggestions_index_name, | ||
configuration=configuration, | ||
) | ||
print(f"Updated query suggestions index for {entity.capitalize()}") |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.