From 7854d444376948c173a5de5556d01cc7fd88e504 Mon Sep 17 00:00:00 2001 From: HeNine <> Date: Wed, 20 Oct 2021 19:45:13 +0200 Subject: [PATCH] Added limit to search --- buscribe-api/buscribeapi/buscribeapi.py | 8 ++++---- buscribe-web/script.js | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/buscribe-api/buscribeapi/buscribeapi.py b/buscribe-api/buscribeapi/buscribeapi.py index e8a8ed2..f832e29 100644 --- a/buscribe-api/buscribeapi/buscribeapi.py +++ b/buscribe-api/buscribeapi/buscribeapi.py @@ -105,15 +105,15 @@ def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset 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 " \ "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: - query += "ORDER BY start_time" + query += "ORDER BY start_time " if limit is not None: - query += "LIMIT %(limit)s" + query += "LIMIT %(limit)s " if offset is not None: - query += "OFFSET %(limit)s" + query += "OFFSET %(limit)s " query += ";" diff --git a/buscribe-web/script.js b/buscribe-web/script.js index 4806122..84fc7fd 100644 --- a/buscribe-web/script.js +++ b/buscribe-web/script.js @@ -4,6 +4,8 @@ function onSiteLoad(e) { function (event) { if (event.key === 'Enter') doSearch() }); + + doSearch(); } function query(text, start_time, end_time) { @@ -19,6 +21,8 @@ function query(text, start_time, end_time) { query_string += `&query=${text}` } + query_string += "&limit=30"; + fetch(`http://localhost:8010/buscribe/json?${query_string}`) .then(response => response.json()) // .then(response => console.log(response.error()))