aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/wqflask')
-rw-r--r--gn2/wqflask/templates/gnqa_search_history.html24
-rw-r--r--gn2/wqflask/views.py13
2 files changed, 36 insertions, 1 deletions
diff --git a/gn2/wqflask/templates/gnqa_search_history.html b/gn2/wqflask/templates/gnqa_search_history.html
index 8d54ad80..c12e7c93 100644
--- a/gn2/wqflask/templates/gnqa_search_history.html
+++ b/gn2/wqflask/templates/gnqa_search_history.html
@@ -47,6 +47,30 @@
{% endfor %}
</ul>
</div>
+ <div class="row">
+ <nav aria-label="Page navigation example"
+ class="col-sm-8 col-sm-offset-2 col-md-6 col-md-offset-3">
+ <ul class="pagination">
+ {% for idx in range(1, num_pages) %}
+ {% if current == idx %}
+ <li class="page-item active">
+ <a class="page-link"
+ hx-swap="innerHTML"
+ hx-target="#swap"
+ hx-get="/gnqna/records?page={{ idx }}">{{ idx }}</a>
+ </li>
+ {% else %}
+ <li class="page-item">
+ <a class="page-link"
+ hx-swap="innerHTML"
+ hx-target="#swap"
+ hx-get="/gnqna/records?page={{ idx }}">{{ idx }}</a>
+ </li>
+ {% endif %}
+ {% endfor %}
+ </ul>
+ </nav>
+ </div>
</div>
</div>
</div>
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index bb086a84..ec252cab 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -16,6 +16,7 @@ import random
import requests
import sys
import traceback
+import math
import uuid
import xlsxwriter
@@ -331,10 +332,20 @@ def get_gnqa_records():
**{"status_code": resp.status_code,
**resp.json()})
+ def get_chunk(items, page, size):
+ start_idx = ((page-1) * size)
+ end_idx = (page*size)
+ return iter(items[start_idx:end_idx])
+
def _success_(resp):
response = resp.json()
+ page = int(request.args.get("page", 1))
+ pagination_size = int(request.args.get("max_size", 10))
+ prev_n_queries = get_chunk(response, page, pagination_size)
return render_template("gnqa_search_history.html",
- prev_queries=response)
+ prev_queries=prev_n_queries,
+ num_pages=math.ceil(len(response)/pagination_size),
+ current=page)
token = session_info()["user"]["token"].either(
lambda err: err, lambda tok: tok["access_token"])
response_url = "/api/llm/search/records"