mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
use unified search instead msearch (#7574)
This commit is contained in:
parent
65ee3f8a8c
commit
ed018320d5
@ -202,7 +202,7 @@ class Wikis2View(APIView):
|
||||
|
||||
if not request.user.permissions.can_add_repo():
|
||||
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to create library.')
|
||||
|
||||
|
||||
if not request.user.permissions.can_create_wiki():
|
||||
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to create wiki.')
|
||||
|
||||
@ -1346,20 +1346,15 @@ class WikiSearch(APIView):
|
||||
results = search_wikis(search_wiki, query, count)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
results = []
|
||||
finally:
|
||||
return Response({"results": results})
|
||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
||||
return Response({"results": results})
|
||||
elif HAS_FILE_SEASEARCH:
|
||||
try:
|
||||
resp = ai_search_wikis(params)
|
||||
if resp.status_code == 500:
|
||||
logger.error('search in wiki error status: %s body: %s', resp.status_code, resp.text)
|
||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
||||
resp_json = resp.json()
|
||||
results, total = ai_search_wikis(params)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
||||
return Response(resp_json, resp.status_code)
|
||||
return Response({"results": results})
|
||||
|
||||
|
||||
class WikiConvertView(APIView):
|
||||
|
@ -239,7 +239,12 @@ def ai_search_wikis(params):
|
||||
headers = {"Authorization": "Token %s" % token}
|
||||
url = urljoin(SEAFEVENTS_SERVER_URL, '/wiki-search')
|
||||
resp = requests.post(url, json=params, headers=headers)
|
||||
return resp
|
||||
if resp.status_code == 500:
|
||||
raise Exception('search in wiki error status: %s body: %s', resp.status_code, resp.text)
|
||||
resp_json = resp.json()
|
||||
results = resp_json.get('results')
|
||||
total = resp_json.get('total')
|
||||
return results, total
|
||||
|
||||
SEARCH_REPOS_LIMIT = 200
|
||||
RELATED_REPOS_PREFIX = 'RELATED_REPOS_'
|
||||
|
Loading…
Reference in New Issue
Block a user