Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Ajout d'une fonction postgres permettant de savoir si une structure a…
Browse files Browse the repository at this point in the history
… un admin
  • Loading branch information
ggounot committed Aug 29, 2024
1 parent e5e9694 commit e892651
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fileignoreconfig:
- filename: queries/metabase/02-utils/structure_has_admin.sql
checksum: 45b9ac4798a7f2f60b0bcd520727578195684a96aca9890f2558ab84e9b2aae5
version: ""
14 changes: 14 additions & 0 deletions queries/metabase/02-utils/structure_has_admin.sql
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit e892651

Please sign in to comment.