-
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.
chore: rename and rewrite project_primary_managers computed column
- Loading branch information
Showing
8 changed files
with
50 additions
and
46 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
31 changes: 0 additions & 31 deletions
31
schema/deploy/computed_columns/project_manager_names_concatenated.sql
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
schema/deploy/computed_columns/project_primary_managers.sql
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,34 @@ | ||
-- Deploy cif:computed_columns/project_primary_managers to pg | ||
|
||
begin; | ||
|
||
create or replace function cif.project_primary_managers(cif.project) | ||
returns text | ||
as $$ | ||
|
||
with names as | ||
(select concat( | ||
cif.cif_user.given_name, | ||
(case | ||
when cif.cif_user.given_name is not null and cif.cif_user.family_name is not null | ||
then ' ' | ||
else null | ||
end), | ||
cif.cif_user.family_name) as full from cif.cif_user | ||
|
||
|
||
where cif.cif_user.id in | ||
(select cif_user_id from cif.project_manager | ||
where cif.project_manager.project_id=$1.id | ||
and cif.project_manager.project_manager_label_id in (select id from cif.project_manager_label where label ilike '%primary%') | ||
) | ||
) | ||
select string_agg(names.full,',') from names; | ||
|
||
$$ language sql stable; | ||
|
||
grant execute on function cif.project_primary_managers to cif_internal, cif_admin; | ||
|
||
comment on function cif.project_primary_managers is 'Returns a concatenated list of the project managers (used for filtering the projects table)'; | ||
|
||
commit; |
7 changes: 0 additions & 7 deletions
7
schema/revert/computed_columns/project_manager_names_concatenated.sql
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
-- Revert cif:computed_columns/project_primary_managers from pg | ||
|
||
begin; | ||
|
||
drop function cif.project_primary_managers; | ||
|
||
commit; |
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 |
---|---|---|
|
@@ -189,3 +189,4 @@ mutations/generate_annual_reports 2022-11-14T18:44:55Z Sepehr Sobhani <sepehr.so | |
tables/project_002_add_contract_number 2022-11-18T17:45:15Z Mike Vesprini <[email protected]> # Add contract_number column | ||
computed_columns/form_change_as_project [computed_columns/[email protected]] 2022-11-21T18:39:44Z Mike Vesprini <[email protected]> # Handle contract_number column being added to project table | ||
computed_columns/project_manager_names_concatenated 2022-11-22T15:24:51Z Brianna Cerkiewicz <briannacerkiewicz@pop-os> # Add computed column to concatenate the full names of all project managers of a project | ||
computed_columns/project_primary_managers 2022-11-22T15:24:51Z Brianna Cerkiewicz <briannacerkiewicz@pop-os> # Add computed column to concatenate the full names of all project managers of a project |
7 changes: 0 additions & 7 deletions
7
schema/verify/computed_columns/project_manager_names_concatenated.sql
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
-- Verify cif:computed_columns/project_primary_managers on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('cif.project_primary_managers(cif.project)'::regprocedure); | ||
|
||
rollback; |