A script example: calculating response time for support

Discuss problems installing or using TrackStudio.

A script example: calculating response time for support

Postby admin » Mon Oct 30, 2006 11:55 pm

I've prepared the following script (for one of our customers) that calculates time interval (in hours), required for developer to answer a problem or a manager to resolve already known problem.

This script take in account working time only (Mon-Fr, 16:00-24:00) and doesn't take in account vacation.

Finally, this script displays who answer the task, number of working hours/days required and message description.

Code: Select all
Object myMsg = null;

Collection messages =  task.getMessages();

for(Iterator it = messages.iterator(); it.hasNext();) {
    Object msg = it.next();
    if (msg.getSubmitter().getPrstatus().getName().equals("developer") || msg.getMstatus().getName().equals("resolve")){
        myMsg = msg;
    }
}

if (myMsg==null)

    return "<font color = red><b>No response</b></font>";
else {
        long submitTime = task.getSubmitdate().getTime().getTime();
        long responseTime = myMsg.getTime().getTime().getTime();
        long responseHours = (responseTime - submitTime) / HOURS;

        Calendar ca = Calendar.getInstance();
        ca.setTimeZone(TimeZone.getTimeZone(sc.getTimezone()));

        for (long i=submitTime;i<responseTime;i+=HOURS) {
            ca.setTimeInMillis(i);
            int day = ca.get(Calendar.DAY_OF_WEEK);
            int hour = ca.get(Calendar.HOUR_OF_DAY);
            int month = ca.get(Calendar.MONTH);
            int mday = ca.get(Calendar.DAY_OF_MONTH);

            boolean vacation = (month == Calendar.DECEMBER && mday > 28) ||
            (month == Calendar.JANUARY && mday < 13) ||
            (month == Calendar.AUGUST && (mday > 5 || mday < 20));

            if (day==Calendar.SATURDAY || day == Calendar.SUNDAY || hour < 16 || vacation)
                responseHours--;
        }

        if (responseHours<0) responseHours = 0;

        String color = "";
        if (responseHours <= 4)
            color = "green";
        if (responseHours>4 && responseHours<=8)
            color = "blue";
        if (responseHours>8 && responseHours <= 24)
            color = "red";
        if (responseHours > 24)
            color = "black";
       
        return (responseHours < 80 ? "0" : "") + responseHours / 8 + " <font color=" + color + ">" + myMsg.getSubmitter().getName() + "</font> - " + responseHours + "<br>" + myMsg.getDescription();
}
Maxim Kramarenko (mailto: maximkr@trackstudio.com)
TrackStudio - Hierarchical Bug & Issue Tracking Software
http://www.trackstudio.com
admin
Site Admin
 
Posts: 8142
Joined: Thu Jan 01, 1970 3:00 am
Location: Smolensk, Russia

Return to TrackStudio Support

Who is online

Users browsing this forum: No registered users and 12 guests