diff --git a/.talismanrc b/.talismanrc new file mode 100644 index 00000000..dcdad882 --- /dev/null +++ b/.talismanrc @@ -0,0 +1,4 @@ +fileignoreconfig: +- filename: queries/metabase/02-utils/structure_has_admin.sql + checksum: 45b9ac4798a7f2f60b0bcd520727578195684a96aca9890f2558ab84e9b2aae5 +version: "" diff --git a/queries/metabase/02-utils/structure_has_admin.sql b/queries/metabase/02-utils/structure_has_admin.sql new file mode 100644 index 00000000..75bc1eec --- /dev/null +++ b/queries/metabase/02-utils/structure_has_admin.sql @@ -0,0 +1,14 @@ +create or replace function structure_has_admin(structure_id_input UUID) +returns BOOLEAN as $$ +BEGIN + RETURN ( + SELECT COUNT(*) > 0 AS has_admin + FROM structures_structuremember + LEFT JOIN users_user ON structures_structuremember.user_id = users_user.id + WHERE structure_id = structure_id_input + AND is_admin = true + AND is_valid = true + AND is_active = true + ); +END; +$$ language plpgsql;