From f0dcc9dafcb280ff522ff4fc8739af4e46cb8768 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 6 Aug 2020 15:41:14 -0700 Subject: handle longer query times --- fatcat_scholar/templates/search.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fatcat_scholar/templates/search.html b/fatcat_scholar/templates/search.html index ee95af3..0216f87 100644 --- a/fatcat_scholar/templates/search.html +++ b/fatcat_scholar/templates/search.html @@ -1,6 +1,14 @@ {% import "search_macros.html" as search_macros %} {% extends "base.html" %} +{% macro format_query_time(query_time_ms) -%} + {% if query_time_ms >= 10000 %} + {{ "{:0.3}".format(hits.query_time_ms/1000.0) }}sec + {% else %} + {{ "{:0.2}".format(hits.query_time_ms/1000.0) }}sec + {% endif %} +{%- endmacro %} + {% block fullmain %}
@@ -23,7 +31,7 @@ {% if hits %} {{ "{:,}".format(hits.count_found) }} Hits - in {{ "{:0.2}".format(hits.query_time_ms/1000.0) }}sec + in {{ format_query_time(hits.query_time_ms) }} {% else %}   {% endif %} @@ -38,7 +46,7 @@ Hits
- in {{ "{:0.2}".format(hits.query_time_ms/1000.0) }}sec + in {{ format_query_time(hits.query_time_ms) }}
{% endif %} -- cgit v1.2.3