Fix version counting in protocol datatable [SCI-7993] (#5019)

This commit is contained in:
aignatov-bio 2023-02-23 15:13:57 +01:00 committed by GitHub
parent fb63c49be5
commit 8906bc25e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -176,7 +176,7 @@ class ProtocolsDatatable < CustomDatatable
get_raw_records_base.select(
'"protocols".*',
'STRING_AGG("protocol_keywords"."name", \', \') AS "protocol_keywords_str"',
'COUNT("protocol_versions"."id") + 1 AS "nr_of_versions"',
'COUNT(DISTINCT("protocol_versions"."id")) + 1 AS "nr_of_versions"', # User assignments generate duplicates
'COUNT("protocol_drafts"."id") AS "nr_of_drafts"',
'COUNT("user_assignments"."id") AS "nr_of_assigned_users"',
'MAX("users"."full_name") AS "full_username_str"', # "Hack" to get single username