简体   繁体   中英

How to set start and end dates for Twilio worker statistics?

I'm trying to get the statistics for a Twilio Taskrouter worker (specifically, I want to know how much total Idle time they've had over their lifetime). I'm using the following query:

getStatisticsByWorkerSid(workerSid){
        return this.workspace.workers(workerSid).statistics({
            start_time: '2017-01-01T01:00:00Z', 
            end_time: '2020-01-01T01:00:00Z'
        }).fetch();
    }

and then I get the cumulative result with:

async getStatisticsByWorkerSid_cumulative(workerSid){
        try{
            var statistics=await this.getStatisticsByWorkerSid(workerSid);
            return statistics.cumulative;
        }
        catch(err){
            console.log("getStatisticsByWorkerSid_cumulative: error "+err);
            return null;
        }
    }

This should give me their statistics for the last 3 years, but instead I get the following result:

{"reservations_timed_out":0,"reservations_rejected":0,"reservations_created":0,"reservations_rescinded":0,"tasks_assigned":0,"start_time":"2019-11-16T03:42:30Z","reservations_wrapup":0,"end_time":"2019-11-16T03:57:30Z","reservations_accepted":0,"activity_durations":[{"avg":900,"min":900,"max":900,"friendly_name":"Offline","sid":"[ActivitySID here]","total":900},{"avg":0,"min":0,"max":0,"friendly_name":"Idle","sid":"[ActivitySID here]","total":0},{"avg":0,"min":0,"max":0,"friendly_name":"Busy","sid":"[ActivitySID here]","total":0},{"avg":0,"min":0,"max":0,"friendly_name":"Reserved","sid":"[ActivitySID here]","total":0},{"avg":0,"min":0,"max":0,"friendly_name":"WrapUp","sid":"[ActivitySID here]","total":0}],"reservations_canceled":0,"reservations_completed":0}

This seems to only give me the most recent 15 minutes' activity.

I've tried it with startDate and endDate instead, but got the same result. How do I actually specify the time range whose cumulative statistics I want to return?

This question is old, yet if you didn't solve this yet, I believe the startDate and endDate are meant to be inside the fetch call (or you can use minutes) and according to my short experience the API allows fetching data from 31 days only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM