diff options
author | Frederick Muriuki Muriithi | 2025-06-09 14:37:13 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-06-09 14:37:13 -0500 |
commit | f7b54e1f8d24aeb13d1afcc1a232d48636f94ef1 (patch) | |
tree | d8e072835a85314717f24bd4ff50c025400e349c /gn_auth/auth/authorisation/resources/mrna.py | |
parent | ec9ac7ddfa71dda21899cb0dcf799d599a2eb180 (diff) | |
download | gn-auth-f7b54e1f8d24aeb13d1afcc1a232d48636f94ef1.tar.gz |
Enable linking multiple data items to a resource in single request.
Diffstat (limited to 'gn_auth/auth/authorisation/resources/mrna.py')
-rw-r--r-- | gn_auth/auth/authorisation/resources/mrna.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/resources/mrna.py b/gn_auth/auth/authorisation/resources/mrna.py index 7fce227..66f8824 100644 --- a/gn_auth/auth/authorisation/resources/mrna.py +++ b/gn_auth/auth/authorisation/resources/mrna.py @@ -26,14 +26,15 @@ def resource_data(cursor: db.DbCursor, def link_data_to_resource( conn: db.DbConnection, resource: Resource, - data_link_id: uuid.UUID) -> dict: + data_link_ids: tuple[uuid.UUID, ...] +) -> tuple[dict, ...]: """Link mRNA Assay data with a resource.""" with db.cursor(conn) as cursor: - params = { + params = tuple({ "resource_id": str(resource.resource_id), "data_link_id": str(data_link_id) - } - cursor.execute( + } for data_link_id in data_link_ids) + cursor.executemany( "INSERT INTO mrna_resources VALUES" "(:resource_id, :data_link_id)", params) |