Commit be4f56c3 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Minor fixes.

parent 259c2019
...@@ -26,7 +26,7 @@ const Options = { ...@@ -26,7 +26,7 @@ const Options = {
*/ */
export default function SearchBar() { export default function SearchBar() {
const suggestionsTimerRef = useRef(null) const suggestionsTimerRef = useRef(null)
const {response: {statistics, pagination}, domain, query, setQuery} = useContext(searchContext) const {response: {statistics, pagination}, domain, query, apiQuery, setQuery} = useContext(searchContext)
const defaultOptions = useMemo(() => { const defaultOptions = useMemo(() => {
return Object.keys(searchQuantities) return Object.keys(searchQuantities)
.map(quantity => searchQuantities[quantity].name) .map(quantity => searchQuantities[quantity].name)
...@@ -81,7 +81,7 @@ export default function SearchBar() { ...@@ -81,7 +81,7 @@ export default function SearchBar() {
} }
suggestionsTimerRef.current = setTimeout(() => { suggestionsTimerRef.current = setTimeout(() => {
setLoading(true) setLoading(true)
api.suggestions_search(quantity, query, size ? null : value, size || 20, true) api.suggestions_search(quantity, apiQuery, size ? null : value, size || 20, true)
.then(response => { .then(response => {
setLoading(false) setLoading(false)
const options = response.suggestions.map(value => Options.join(quantity, value)) const options = response.suggestions.map(value => Options.join(quantity, value))
......
...@@ -680,9 +680,12 @@ class RepoSuggestionsResource(Resource): ...@@ -680,9 +680,12 @@ class RepoSuggestionsResource(Resource):
try: try:
search_request.statistic(quantity, size=size, include=include, order=dict(_key='desc')) search_request.statistic(quantity, size=size, include=include, order=dict(_key='desc'))
results = search_request.execute() results = search_request.execute()
values = results['statistics'][quantity] values = {
value: metric['code_runs']
for value, metric in results['statistics'][quantity].items()
if metric['code_runs'] > 0}
results['suggestions'] = sorted( results['suggestions'] = sorted(
values.keys(), key=lambda value: values[value]['code_runs'], reverse=True) values.keys(), key=lambda value: values[value], reverse=True)
return results, 200 return results, 200
except KeyError as e: except KeyError as e:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment