Skip to content

Commit

Permalink
feat: update function logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dleard committed Jun 23, 2020
1 parent fbcfbef commit 1b264ea
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ returns void as $$
calls_past_minute int;
defer_run_multiplier int;
begin
insert into ggircs_portal_private.graphile_worker_timestamp(called_at) values (now());
calls_past_minute := (select count(*) from ggircs_portal_private.graphile_worker_timestamp where called_at between (now() - interval '1 minute') and now());
calls_past_minute := (select count(*) from ggircs_portal_private.graphile_worker_timestamp where called_at > (now() - interval '1 minute'));
defer_run_multiplier := (calls_past_minute/100);

perform graphile_worker.add_job(task, payload, run_at := NOW() + ((defer_run_multiplier) * INTERVAL '1 minute'));
perform graphile_worker.add_job(task, payload, run_at := now() + ((defer_run_multiplier) * INTERVAL '1 minute'));
insert into ggircs_portal_private.graphile_worker_timestamp(called_at) values (now() + ((defer_run_multiplier) * INTERVAL '1 minute'));

end;
$$ language plpgsql volatile security definer;
Expand Down

0 comments on commit 1b264ea

Please sign in to comment.