Hey everyone,
I’ve been working on a script to pull historical queue metrics for our Chicago team. The goal is to get adherence data for the last 30 days. I’m using the Python SDK because it handles the OAuth token refresh for me, which is nice.
Here is the weird thing. I set pageSize to 100 in my query. The docs say the max is 1000, so 100 should be fine. But the response paging object looks totally off. It says pageCount is 1, but I know there are way more than 100 records in that date range.
Here is the code snippet I am using:
from genesyscloud import analytics_api_client
from genesyscloud.analytics.models import QueryIntervalMetricsRequest
client = analytics_api_client.AnalyticsApiClient()
request = QueryIntervalMetricsRequest(
view="queue_metrics",
group_by=["queueId"],
select=["handleTime"],
where="queueId='my-queue-id'",
interval="P1D",
from_time="2023-10-01T00:00:00.000Z",
to_time="2023-10-31T23:59:59.999Z"
)
# I thought I could pass paging directly here but the SDK requires a separate object or query params
# Let's try the raw query method to see if it helps
response = client.get_analytics_queryintervalmetrics(
queryintervalmetricsrequest=request,
page_size=100,
page_number=1
)
print(response.paging)
The output for response.paging is:
{'pageSize': 100, 'pageNumber': 1, 'total': 500, 'pageCount': 1}
Wait, if total is 500 and pageSize is 100, why is pageCount 1? Shouldn’t it be 5?
I tried incrementing page_number to 2 in the next call. The API returns an empty array for data. It acts like page 1 contains everything, even though the array length is only 100.
Am I misreading the paging object? Or is the total field just a count of available metrics points, not the actual returned records? I need to loop through pages to get all 500 items. If pageCount is 1, my loop exits immediately.
Any ideas on how to paginate this correctly?