refactor CancelSession and updateStates to be idempotent (#390)
This commit is contained in:
3 files changed
+61
-17
No files matched your search
@@ -18,6 +18,27 @@ with not_active as (
|
||||
select * from not_active;
|
||||
`
|
||||
|
||||
// updateSessionState checks that we don't already have a row for the new
|
||||
// state before inserting a new state.
|
||||
updateSessionState = `
|
||||
insert into session_state(session_id, state)
|
||||
select
|
||||
$1::text, $2
|
||||
from
|
||||
session s
|
||||
where
|
||||
s.public_id = $1::text and
|
||||
s.public_id not in (
|
||||
select
|
||||
session_id
|
||||
from
|
||||
session_state
|
||||
where
|
||||
session_id = $1::text and
|
||||
state = $2
|
||||
)
|
||||
`
|
||||
|
||||
terminateSessionCte = `
|
||||
insert into session_state
|
||||
with terminated as (
|
||||
|
||||
Reference in new issue
Block a user