Skip to content

Commit

Permalink
PISTON-638: Ensure request time range is within configured acdc clean…
Browse files Browse the repository at this point in the history
…up window (2600hz#5313)
  • Loading branch information
aisconn authored and k-anderson committed Dec 10, 2018
1 parent 6895a69 commit 50a1875
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions applications/acdc/src/cb_agents.erl
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,12 @@ fetch_all_current_agent_stats(Context) ->
-spec fetch_all_current_stats(cb_context:context(), kz_term:api_binary()) -> cb_context:context().
fetch_all_current_stats(Context, AgentId) ->
Now = kz_time:now_s(),
Yday = Now - ?SECONDS_IN_DAY,
From = Now - min(?SECONDS_IN_DAY, ?ACDC_CLEANUP_WINDOW),

Req = props:filter_undefined(
[{<<"Account-ID">>, cb_context:account_id(Context)}
,{<<"Agent-ID">>, AgentId}
,{<<"Start-Range">>, Yday}
,{<<"Start-Range">>, From}
,{<<"End-Range">>, Now}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
]),
Expand Down Expand Up @@ -342,12 +342,12 @@ fetch_current_status(Context, AgentId, 'true') ->
cb_context:context().
fetch_all_current_statuses(Context, AgentId, Status) ->
Now = kz_time:now_s(),
Yday = Now - ?SECONDS_IN_DAY,
From = Now - min(?SECONDS_IN_DAY, ?ACDC_CLEANUP_WINDOW),

Opts = props:filter_undefined(
[{<<"Status">>, Status}
,{<<"Agent-ID">>, AgentId}
,{<<"Start-Range">>, Yday}
,{<<"Start-Range">>, From}
,{<<"End-Range">>, Now}
,{<<"Limit">>, cb_context:req_value(Context, <<"limit">>)}
]),
Expand Down
5 changes: 5 additions & 0 deletions applications/acdc/src/cb_queues.erl
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,15 @@ fetch_all_queue_stats(Context) ->
-spec fetch_all_current_queue_stats(cb_context:context()) -> cb_context:context().
fetch_all_current_queue_stats(Context) ->
lager:debug("querying for all recent stats"),
Now = kz_time:now_s(),
From = Now - min(?SECONDS_IN_DAY, ?ACDC_CLEANUP_WINDOW),

Req = props:filter_undefined(
[{<<"Account-ID">>, cb_context:account_id(Context)}
,{<<"Status">>, cb_context:req_value(Context, <<"status">>)}
,{<<"Agent-ID">>, cb_context:req_value(Context, <<"agent_id">>)}
,{<<"Start-Range">>, From}
,{<<"End-Range">>, Now}
| kz_api:default_headers(?APP_NAME, ?APP_VERSION)
]),
fetch_from_amqp(Context, Req).
Expand Down

0 comments on commit 50a1875

Please sign in to comment.