Skip to content

Commit

Permalink
chore: rename and rewrite project_primary_managers computed column
Browse files Browse the repository at this point in the history
  • Loading branch information
BCerki committed Nov 28, 2022
1 parent 6da4074 commit 4ba01af
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app/postgraphile.tags.json5
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
sortable: true,
},
},
"cif.project_manager_names_concatenated": {
"cif.project_primary_managers": {
tags: {
filterable: true,
},
Expand Down

This file was deleted.

34 changes: 34 additions & 0 deletions schema/deploy/computed_columns/project_primary_managers.sql
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;

This file was deleted.

7 changes: 7 additions & 0 deletions schema/revert/computed_columns/project_primary_managers.sql
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;
1 change: 1 addition & 0 deletions schema/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -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

This file was deleted.

7 changes: 7 additions & 0 deletions schema/verify/computed_columns/project_primary_managers.sql
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;

0 comments on commit 4ba01af

Please sign in to comment.