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

created changes view #32

Merged
merged 1 commit into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1 @@
DROP VIEW watchops.changes;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CREATE OR REPLACE VIEW watchops.changes AS (
WITH all_commits AS
(
SELECT source, event_type, json_parse(json_serialize(metadata)) AS metadata
FROM watchops.events_raw
WHERE event_type = 'push'
and json_serialize(metadata) LIKE '%"commits":[%'
),
commit AS
(
SELECT index, i.source, i.event_type, element.timestamp AS time_created, element.id AS change_id
FROM all_commits AS i, i.metadata.commits AS element AT index
)
SELECT source, event_type, change_id, date_trunc('second', TO_TIMESTAMP(CAST(time_created AS VARCHAR), 'YYYY-MM-DDTHH:MI:SS')) AS time_created
FROM commit
)