Added limit to search

pull/414/head
HeNine 3 years ago
parent 4682742c20
commit 7854d44437

@ -105,15 +105,15 @@ def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset
query += "AND transcription_line_ts @@ " \ query += "AND transcription_line_ts @@ " \
"(CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery " \ "(CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery " \
"ORDER BY ts_rank_cd(transcription_line_ts, (CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery) DESC, " \ "ORDER BY ts_rank_cd(transcription_line_ts, (CASE WHEN websearch_to_tsquery(%(text_query)s)::text != '' THEN websearch_to_tsquery(%(text_query)s)::text || ':*' ELSE '' END)::tsquery) DESC, " \
"start_time" "start_time "
else: else:
query += "ORDER BY start_time" query += "ORDER BY start_time "
if limit is not None: if limit is not None:
query += "LIMIT %(limit)s" query += "LIMIT %(limit)s "
if offset is not None: if offset is not None:
query += "OFFSET %(limit)s" query += "OFFSET %(limit)s "
query += ";" query += ";"

@ -4,6 +4,8 @@ function onSiteLoad(e) {
function (event) { function (event) {
if (event.key === 'Enter') doSearch() if (event.key === 'Enter') doSearch()
}); });
doSearch();
} }
function query(text, start_time, end_time) { function query(text, start_time, end_time) {
@ -19,6 +21,8 @@ function query(text, start_time, end_time) {
query_string += `&query=${text}` query_string += `&query=${text}`
} }
query_string += "&limit=30";
fetch(`http://localhost:8010/buscribe/json?${query_string}`) fetch(`http://localhost:8010/buscribe/json?${query_string}`)
.then(response => response.json()) .then(response => response.json())
// .then(response => console.log(response.error())) // .then(response => console.log(response.error()))

Loading…
Cancel
Save