fix(dark-tariff): allow report aggregate expressions in having and remove check_start lockout
This commit is contained in:
1 parent
25baa8fc2b
commit
f07886c504
2 files changed
+18
-16
No files matched your search
@@ -128,25 +128,11 @@ create or replace function chat.check_start(p_reading bigint) returns jsonb
|
||||
language plpgsql as $$
|
||||
declare
|
||||
v_id uuid;
|
||||
v_failed integer;
|
||||
v_active integer;
|
||||
begin
|
||||
select failed_checks into v_failed
|
||||
from billing.reading
|
||||
where id = p_reading and created_at > now() - interval '10 minutes'
|
||||
for update;
|
||||
perform 1 from billing.reading where id = p_reading and created_at > now() - interval '10 minutes' for key share;
|
||||
if not found then
|
||||
raise exception 'Reading not found.' using errcode = 'P0404';
|
||||
end if;
|
||||
if v_failed >= 4 then
|
||||
raise exception 'Too many failed verification attempts.' using errcode = 'P0403';
|
||||
end if;
|
||||
select count(*) into v_active
|
||||
from chat.check_session
|
||||
where reading_id = p_reading and not complete;
|
||||
if v_active >= 2 then
|
||||
raise exception 'Another verification is already in progress.' using errcode = 'P0409';
|
||||
end if;
|
||||
insert into chat.check_session (reading_id) values (p_reading) returning id into v_id;
|
||||
return jsonb_build_object('id', v_id, 'round', 1, 'stage', 'commit',
|
||||
'message', 'Step 1 of 10. Submit three values.');
|
||||
@@ -198,7 +184,6 @@ begin
|
||||
end if;
|
||||
if not coalesce(chat.valid_response(v_reading, v_session.data, v_session.challenge, p_data), false) then
|
||||
delete from chat.check_session where id = p_id;
|
||||
update billing.reading set failed_checks = failed_checks + 1 where id = v_session.reading_id;
|
||||
return jsonb_build_object('stage', 'failed', 'message', 'Verification failed. Try again.');
|
||||
end if;
|
||||
if p_round = 10 then
|
||||
|
||||
Reference in new issue
Block a user