Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed deloyments view - deleted json_serialize function #43

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ CREATE OR REPLACE VIEW watchops.deployments AS
WITH deploys AS (
SELECT
source,
json_extract_path_text(json_serialize(metadata), 'deployment', 'id') as deploy_id,
cast(metadata."deployment"."id" as varchar) as deploy_id,
time_created,
CASE WHEN source like '%circleci%' then json_extract_path_text(json_serialize(metadata), 'workflow', 'id')
WHEN source like '%github%' then json_extract_path_text(json_serialize(metadata), 'deployment', 'sha')
WHEN source like '%gitlab%' then json_extract_path_text(json_serialize(metadata), 'commit', 'id') end as main_commit
CASE WHEN source like '%circleci%' then cast(metadata."workflow"."id" as varchar)
WHEN source like '%github%' then cast(metadata."deployment"."sha" as varchar)
WHEN source like '%gitlab%' then cast(metadata."commit"."id" as varchar)
end as main_commit
FROM watchops.events_raw
WHERE ((source like '%circleci%' and json_extract_path_text(json_serialize(metadata), 'status') = 'SUCCESS')
OR (source like 'github%' and event_type = 'deployment_status' and json_extract_path_text(json_serialize(metadata), 'deployment_status', 'state') = 'success')
OR (source like 'gitlab%' and event_type = 'pipeline' and json_extract_path_text(json_serialize(metadata), 'object_attributes', 'status') = 'success'))
WHERE ((source like '%circleci%' and cast(metadata."status" as varchar) = 'SUCCESS'
OR (source like 'github%' and event_type = 'deployment_status' and cast(metadata."deployment_status"."state" as varchar) = 'success')
OR (source like 'gitlab%' and event_type = 'pipeline' and cast(metadata."object_attributes"."status" as varchar) = 'success')))
)
select * from deploys