diff options
author | Frederick Muriuki Muriithi | 2023-07-31 09:01:15 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2023-07-31 09:01:15 +0300 |
commit | bc3439298074e8139f9d8af8438a224616cf681a (patch) | |
tree | 5f9e1d888b7958b4643bfdde1bd3ce62e13d996b /gn3/auth/authorisation | |
parent | effc12fbd6ffd4a388f4aa31425ba8a9b33faa82 (diff) | |
download | genenetwork3-bc3439298074e8139f9d8af8438a224616cf681a.tar.gz |
Fix bugs. Return resource without data items.
* Fix bugs introduced while attempting pagination.
* Return resource object without attached data items.
Diffstat (limited to 'gn3/auth/authorisation')
-rw-r--r-- | gn3/auth/authorisation/resources/models.py | 7 | ||||
-rw-r--r-- | gn3/auth/authorisation/resources/views.py | 4 |
2 files changed, 5 insertions, 6 deletions
diff --git a/gn3/auth/authorisation/resources/models.py b/gn3/auth/authorisation/resources/models.py index b634a35..45d316c 100644 --- a/gn3/auth/authorisation/resources/models.py +++ b/gn3/auth/authorisation/resources/models.py @@ -243,8 +243,7 @@ def mrna_resource_data(cursor: db.DbCursor, "INNER JOIN linked_mrna_data AS lmr " "ON mr.data_link_id=lmr.data_link_id " "WHERE mr.resource_id=?") + ( - f" LIMIT {limit}" if bool(limit) else "") ( - f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")), + f" LIMIT {limit} OFFSET {offset}" if bool(limit) else "")), (str(resource_id),)) return cursor.fetchall() @@ -294,11 +293,11 @@ def resource_by_id( {"id": str(resource_id)}) row = cursor.fetchone() if row: - return attach_resource_data(cursor, Resource( + return Resource( group_by_id(conn, UUID(row["group_id"])), UUID(row["resource_id"]), row["resource_name"], resource_category_by_id(conn, row["resource_category_id"]), - bool(int(row["public"])))) + bool(int(row["public"]))) raise NotFoundError(f"Could not find a resource with id '{resource_id}'") diff --git a/gn3/auth/authorisation/resources/views.py b/gn3/auth/authorisation/resources/views.py index 2e6c244..c39d4ab 100644 --- a/gn3/auth/authorisation/resources/views.py +++ b/gn3/auth/authorisation/resources/views.py @@ -96,13 +96,13 @@ def view_resource_data(resource_id: uuid.UUID) -> Response: with require_oauth.acquire("profile group resource") as the_token: db_uri = app.config["AUTH_DB"] count_per_page = __safe_get_requests_count__("count_per_page") - page = (__safe_get_requests_page__("page") - 1) + offset = (__safe_get_requests_page__("page") - 1) with db.connection(db_uri) as conn: resource = resource_by_id(conn, the_token.user, resource_id) return jsonify(resource_data( conn, resource, - ((page * count_per_page) if bool(count_per_page) else page), + ((offset * count_per_page) if bool(count_per_page) else offset), count_per_page)) @resources.route("/data/link", methods=["POST"]) |