-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve filters to support more foundations
Signed-off-by: Sergio Castaño Arteaga <[email protected]> Signed-off-by: Cintia Sanchez Garcia <[email protected]> Co-authored-by: Sergio Castaño Arteaga <[email protected]> Co-authored-by: Cintia Sanchez Garcia <[email protected]>
- Loading branch information
1 parent
157b659
commit ffba978
Showing
10 changed files
with
353 additions
and
220 deletions.
There are no files selected for viewing
247 changes: 135 additions & 112 deletions
247
database/migrations/functions/issues/get_issues_filters.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 |
---|---|---|
@@ -1,123 +1,146 @@ | ||
-- Return the filters that can be used when searching for issues in json format. | ||
create or replace function get_issues_filters() | ||
returns json as $$ | ||
select json_build_array( | ||
json_build_object( | ||
'title', 'Foundation', | ||
'key', 'foundation', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', display_name, | ||
'value', foundation_id | ||
)), '[]') | ||
from ( | ||
select foundation_id, display_name | ||
from foundation | ||
order by foundation_id asc | ||
) f | ||
) | ||
select json_build_object( | ||
'filters', json_build_array( | ||
json_build_object( | ||
'title', 'Foundation', | ||
'key', 'foundation', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', display_name, | ||
'value', foundation_id | ||
)), '[]') | ||
from ( | ||
select foundation_id, display_name | ||
from foundation | ||
order by foundation_id asc | ||
) f | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Maturity', | ||
'key', 'maturity', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(maturity), | ||
'value', maturity | ||
)), '[]') | ||
from ( | ||
select distinct maturity | ||
from project | ||
where maturity is not null | ||
order by maturity asc | ||
) m | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Project', | ||
'key', 'project', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', coalesce(display_name, name), | ||
'value', name | ||
)), '[]') | ||
from ( | ||
select distinct p.display_name, p.name | ||
from project p | ||
join repository r using (project_id) | ||
join issue i using (repository_id) | ||
order by name asc | ||
) m | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Area', | ||
'key', 'area', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(area::text), | ||
'value', area::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::area)) as area | ||
) a | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Kind', | ||
'key', 'kind', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(kind::text), | ||
'value', kind::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::kind)) as kind | ||
) k | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Difficulty', | ||
'key', 'difficulty', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(difficulty::text), | ||
'value', difficulty::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::difficulty)) as difficulty | ||
) d | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Language', | ||
'key', 'language', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', language, | ||
'value', language | ||
)), '[]') | ||
from ( | ||
select distinct(unnest(languages)) as language | ||
from repository | ||
order by language asc | ||
) m | ||
) | ||
), | ||
'{ | ||
"title": "Other", | ||
"options": [ | ||
{ | ||
"name": "Good first issue", | ||
"key": "good_first_issue", | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "Mentor available", | ||
"key": "mentor_available", | ||
"type": "boolean" | ||
} | ||
] | ||
}'::jsonb | ||
), | ||
json_build_object( | ||
'title', 'Maturity', | ||
'key', 'maturity', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(maturity), | ||
'value', maturity | ||
)), '[]') | ||
'extra', json_build_object( | ||
'maturity', ( | ||
select coalesce(json_object_agg(foundation_id, maturities), '{}') | ||
from ( | ||
select distinct maturity | ||
select distinct foundation_id, array_agg(distinct maturity) as maturities | ||
from project | ||
where maturity is not null | ||
order by maturity asc | ||
) m | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Project', | ||
'key', 'project', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', coalesce(display_name, name), | ||
'value', name | ||
)), '[]') | ||
from ( | ||
select distinct p.display_name, p.name | ||
from project p | ||
join repository r using (project_id) | ||
join issue i using (repository_id) | ||
order by name asc | ||
) m | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Area', | ||
'key', 'area', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(area::text), | ||
'value', area::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::area)) as area | ||
) a | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Kind', | ||
'key', 'kind', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(kind::text), | ||
'value', kind::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::kind)) as kind | ||
) k | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Difficulty', | ||
'key', 'difficulty', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', initcap(difficulty::text), | ||
'value', difficulty::text | ||
)), '[]') | ||
from ( | ||
select unnest(enum_range(null::difficulty)) as difficulty | ||
) d | ||
) | ||
), | ||
json_build_object( | ||
'title', 'Language', | ||
'key', 'language', | ||
'options', ( | ||
select coalesce(json_agg(json_build_object( | ||
'name', language, | ||
'value', language | ||
)), '[]') | ||
group by foundation_id | ||
order by foundation_id asc | ||
) as maturities | ||
), | ||
'project', ( | ||
select coalesce(json_object_agg(foundation_id, projects), '{}') | ||
from ( | ||
select distinct(unnest(languages)) as language | ||
from repository | ||
order by language asc | ||
) m | ||
select distinct foundation_id, array_agg(distinct name) as projects | ||
from project | ||
group by foundation_id | ||
order by foundation_id asc | ||
) as projects | ||
) | ||
), | ||
'{ | ||
"title": "Other", | ||
"options": [ | ||
{ | ||
"name": "Good first issue", | ||
"key": "good_first_issue", | ||
"type": "boolean" | ||
}, | ||
{ | ||
"name": "Mentor available", | ||
"key": "mentor_available", | ||
"type": "boolean" | ||
} | ||
] | ||
}'::jsonb | ||
) | ||
); | ||
$$ language 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
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
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
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
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 |
---|---|---|
|
@@ -63,6 +63,10 @@ | |
max-height: 300px; | ||
} | ||
|
||
.tooltipArrow { | ||
margin-top: 7px; | ||
} | ||
|
||
.dropdown label { | ||
font-size: 0.8rem; | ||
} | ||
|
Oops, something went wrong.