aboutsummaryrefslogtreecommitdiff
path: root/uploader/publications/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/publications/views.py')
-rw-r--r--uploader/publications/views.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/uploader/publications/views.py b/uploader/publications/views.py
index 8a65ff2..137052b 100644
--- a/uploader/publications/views.py
+++ b/uploader/publications/views.py
@@ -15,11 +15,12 @@ from flask import (
from uploader.authorisation import require_login
from .models import (
- fetch_publications,
fetch_publication_by_id,
create_new_publications,
fetch_publication_phenotypes)
+from .datatables import fetch_publications
+
from gn_libs.debug import __pk__
pubbp = Blueprint("publications", __name__)
@@ -44,23 +45,16 @@ def list_publications():
_search = request.args["search[value]"]
with (database_connection(app.config["SQL_URI"]) as conn,
conn.cursor(cursorclass=DictCursor) as cursor):
- cursor.execute("SELECT COUNT(*) FROM Publication")
- _totalrows = int(cursor.fetchone()["COUNT(*)"])
- _publications = tuple({
- **row, "index": idx
- } for idx,row in enumerate(
- fetch_publications(
- conn,
- _search,
- offset=_length * (_page-1),
- limit=_length),
- start=(_start + 1)))
+ _publications, _current_rows, _totalfiltered, _totalrows = fetch_publications(
+ conn,
+ _search,
+ offset=_start,
+ limit=_length)
return json.dumps({
"draw": _page,
"recordsTotal": _totalrows,
- "recordsFiltered": (
- len(_publications) if bool(_search) else _totalrows),
+ "recordsFiltered": _totalfiltered,
"publications": _publications,
"status": "success"
})