Skip to content

Commit

Permalink
add search filename only and suffixes (#5892)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang authored Jan 17, 2024
1 parent 73afa03 commit 8cc6404
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions seahub/ai/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Search(APIView):
def post(self, request):
query = request.data.get('query')
search_repo = request.data.get('search_repo', 'all')
suffixes = request.data.get('suffixes', '')

try:
count = int(request.data.get('count'))
Expand All @@ -96,7 +97,7 @@ def post(self, request):
repos = get_search_repos(username, org_id)[:SEARCH_REPOS_LIMIT]
cache.set(key, repos, RELATED_REPOS_CACHE_TIMEOUT)

is_all_repo = True
search_filename_only = True
else:
try:
repo = seafile_api.get_repo(search_repo)
Expand All @@ -111,15 +112,17 @@ def post(self, request):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

repos = [(repo.id, repo.origin_repo_id, repo.origin_path, repo.name)]
is_all_repo = False
search_filename_only = False

searched_repos, repos_map = format_repos(repos)

suffixes = [suffix.strip() for suffix in suffixes.split(',') if suffix.strip()]
params = {
'query': query,
'repos': searched_repos,
'count': count,
'is_all_repo': is_all_repo,
'suffixes': suffixes,
'search_filename_only': search_filename_only,
}

try:
Expand Down

0 comments on commit 8cc6404

Please sign in to comment.