-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create
submission_services_log
view (#3144)
- Loading branch information
1 parent
c81d650
commit 1a73dcb
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
hasura.planx.uk/migrations/1715689232003_create view submission services log /down.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 |
---|---|---|
@@ -0,0 +1 @@ | ||
drop view if exists public.submission_services_log cascade; |
45 changes: 45 additions & 0 deletions
45
hasura.planx.uk/migrations/1715689232003_create view submission services log /up.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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
create or replace view public.submission_services_log as | ||
with payments as ( | ||
select | ||
session_id, | ||
payment_id::text as event_id, | ||
'Pay' as event_type, | ||
initcap(status) as status, | ||
'{}'::jsonb as response, | ||
created_at | ||
from payment_status | ||
where status != 'created' | ||
and created_at >= '2024-01-01' | ||
), submissions as ( | ||
select | ||
(seil.request -> 'payload' -> 'payload' ->> 'sessionId')::uuid as session_id, | ||
se.id as event_id, | ||
case | ||
when se.webhook_conf::text like '%bops%' then 'Submit to BOPS' | ||
when se.webhook_conf::text like '%uniform%' then 'Submit to Uniform' | ||
when se.webhook_conf::text like '%email-submission%' then 'Send to email' | ||
when se.webhook_conf::text like '%upload-submission%' then 'Upload to AWS S3' | ||
else se.webhook_conf::text | ||
end as event_type, | ||
case | ||
when seil.status = 200 then 'Success' | ||
else format('Failed (%s)', seil.status) | ||
end as status, | ||
seil.response::jsonb, | ||
seil.created_at | ||
from hdb_catalog.hdb_scheduled_events se | ||
left join hdb_catalog.hdb_scheduled_event_invocation_logs seil on seil.event_id = se.id | ||
where se.webhook_conf::text not like '%email/%' | ||
and seil.created_at >= '2024-01-01' | ||
), all_events as ( | ||
select * from payments | ||
union all | ||
select * from submissions | ||
) | ||
SELECT | ||
ls.flow_id, | ||
ae.* | ||
FROM all_events ae | ||
left join public.lowcal_sessions ls on ls.id = ae.session_id | ||
WHERE ls.flow_id is not null | ||
order by ae.created_at desc; |