Skip to content

Commit

Permalink
feat: create submission_services_log view (#3144)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored May 15, 2024
1 parent c81d650 commit 1a73dcb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,9 @@
- locked_at:
_is_null: true
check: null
- table:
name: submission_services_log
schema: public
- table:
name: submission_services_summary
schema: public
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drop view if exists public.submission_services_log cascade;
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;

0 comments on commit 1a73dcb

Please sign in to comment.