Skip to content

Commit

Permalink
Update realtime_analytics.rst (#943)
Browse files Browse the repository at this point in the history
Because the current minute (`date_trunc('minute', now())`) has not passed yet, records that are inserted in the current minute but after the function execution will never be aggregated into `http_request_1min` table. We need to assign one minute before the current minute (`date_trunc('minute', now() - interval '1 minute')`) to `curr_rollup_time`.
  • Loading branch information
MohammadAlavi1986 committed Oct 7, 2022
1 parent a2b4bd1 commit c14027c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion use_cases/realtime_analytics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The following function wraps the rollup query up for convenience.
-- function to do the rollup
CREATE OR REPLACE FUNCTION rollup_http_request() RETURNS void AS $$
DECLARE
curr_rollup_time timestamptz := date_trunc('minute', now());
curr_rollup_time timestamptz := date_trunc('minute', now() - interval '1 minute');
last_rollup_time timestamptz := minute from latest_rollup;
BEGIN
INSERT INTO http_request_1min (
Expand Down

0 comments on commit c14027c

Please sign in to comment.