This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout d'une fonction postgres permettant de savoir si une structure a…
… un admin
- Loading branch information
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |