|
|
@ -88,20 +88,24 @@ def get_json():
|
|
|
|
|
|
|
|
|
|
|
|
results = fetch_lines(db_conn, start_time, end_time, query, limit, offset)
|
|
|
|
results = fetch_lines(db_conn, start_time, end_time, query, limit, offset)
|
|
|
|
|
|
|
|
|
|
|
|
return jsonify([{"start_time": row.start_time.isoformat(),
|
|
|
|
return jsonify([{"id": row.id,
|
|
|
|
|
|
|
|
"start_time": row.start_time.isoformat(),
|
|
|
|
"start_bus_time": round_bus_time(row.start_time - app.bustime_start),
|
|
|
|
"start_bus_time": round_bus_time(row.start_time - app.bustime_start),
|
|
|
|
"end_time": row.end_time.isoformat(),
|
|
|
|
"end_time": row.end_time.isoformat(),
|
|
|
|
"end_bus_time": round_bus_time(row.start_time - app.bustime_start),
|
|
|
|
"end_bus_time": round_bus_time(row.start_time - app.bustime_start),
|
|
|
|
|
|
|
|
"verifier": row.verifier,
|
|
|
|
"text": row.transcription_line} for row in results])
|
|
|
|
"text": row.transcription_line} for row in results])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset=None):
|
|
|
|
def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset=None):
|
|
|
|
query = "SELECT * FROM buscribe_transcriptions WHERE start_time > %(start_time)s AND end_time < %(end_time)s "
|
|
|
|
query = "SELECT * FROM buscribe_all_transcriptions WHERE start_time > %(start_time)s AND end_time < %(end_time)s "
|
|
|
|
|
|
|
|
|
|
|
|
if ts_query is not None:
|
|
|
|
if ts_query is not None:
|
|
|
|
query += "AND to_tsvector(transcription_line) @@ websearch_to_tsquery(%(text_query)s) " \
|
|
|
|
query += "AND transcription_line_ts @@ (websearch_to_tsquery(%(text_query)s)::text ||':*')::tsquery " \
|
|
|
|
"ORDER BY ts_rank_cd(to_tsvector(transcription_line), websearch_to_tsquery(%(text_query)s)) DESC, " \
|
|
|
|
"ORDER BY ts_rank_cd(transcription_line_ts, (websearch_to_tsquery(%(text_query)s)::text ||':*')::tsquery) DESC, " \
|
|
|
|
"start_time"
|
|
|
|
"start_time"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
query += "ORDER BY start_time"
|
|
|
|
|
|
|
|
|
|
|
|
if limit is not None:
|
|
|
|
if limit is not None:
|
|
|
|
query += "LIMIT %(limit)s"
|
|
|
|
query += "LIMIT %(limit)s"
|
|
|
@ -111,8 +115,6 @@ def fetch_lines(db_conn, start_time, end_time, ts_query=None, limit=None, offset
|
|
|
|
|
|
|
|
|
|
|
|
query += ";"
|
|
|
|
query += ";"
|
|
|
|
|
|
|
|
|
|
|
|
print(query)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return database.query(db_conn, query,
|
|
|
|
return database.query(db_conn, query,
|
|
|
|
start_time=start_time if start_time is not None else '-infinity',
|
|
|
|
start_time=start_time if start_time is not None else '-infinity',
|
|
|
|
end_time=end_time if end_time is not None else 'infinity',
|
|
|
|
end_time=end_time if end_time is not None else 'infinity',
|
|
|
|