Skip to content

Commit

Permalink
Merge pull request #17 from psarando/CORE-1517
Browse files Browse the repository at this point in the history
CORE-1517 Add app_versions_listing view
  • Loading branch information
psarando authored Aug 23, 2022
2 parents adecc45 + a038478 commit e89e330
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions migrations/000034_app_versions_listing.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BEGIN;

SET search_path = public, pg_catalog;

DROP VIEW IF EXISTS app_versions_listing;

COMMIT;
48 changes: 48 additions & 0 deletions migrations/000034_app_versions_listing.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
BEGIN;

SET search_path = public, pg_catalog;

--
-- A view containing the top-level information needed for app version listings.
--
CREATE OR REPLACE VIEW app_versions_listing AS
SELECT apps.id,
apps."name",
apps.description,
apps.wiki_url,
integration.integrator_name,
integration.integrator_email,
v.id AS version_id,
v.version,
v.version_order,
v.deleted,
v.disabled,
v.integration_date,
v.edited_date,
COUNT(steps.*) AS step_count,
COUNT(t.tool_id) AS tool_count,
COUNT(t.external_app_id) AS external_app_count,
COUNT(t.id) AS task_count,
CASE WHEN COUNT(DISTINCT tt.name) = 0 THEN 'unknown'
WHEN COUNT(DISTINCT tt.name) > 1 THEN 'mixed'
ELSE MAX(tt.name)
END AS overall_job_type,
integration.user_id AS integrator_id,
u.username AS integrator_username,
array_agg(tt.name) as job_types
FROM apps
LEFT JOIN app_versions v ON apps.id = v.app_id
LEFT JOIN integration_data integration ON integration.id = v.integration_data_id
LEFT JOIN users u ON integration.user_id = u.id
LEFT JOIN app_steps steps ON steps.app_version_id = v.id
LEFT JOIN tasks t ON steps.task_id = t.id
LEFT JOIN tools tool ON t.tool_id = tool.id
LEFT JOIN tool_types tt ON tool.tool_type_id = tt.id
GROUP BY apps.id,
integration.integrator_name,
integration.integrator_email,
integration.user_id,
u.username,
v.id;

COMMIT;

0 comments on commit e89e330

Please sign in to comment.