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();
}