Calculate the hub time for a ticket for each team

57 views Asked by At

I need to find the total time a ticket spent in each team domain. The time start for one team from the arrival of the ticket until it leaves their domain to another group. If the ticket comes back again it adds up to the previous counter and stop if it leaves again and so on. the result at the end is to list (and sort) each team by longest time and say a result like the below

Central Team Office = 13H:59M

Network Group 1 = 1H:35M

SOC Cable team = 0H:25M

Options are excel spreadsheet , bookmarklet or jquery script to get the result.

Sample CSV data below is a single ticket history data separated by a comma

Action time,Status,RC,Referal Group,Assignee,User,User Group
8/16/2022 21:39,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 21:39,Referred,,Network Group 1,,,Network Group 2
8/16/2022 21:35,Assigned,,Network Group 2,,,Network Group 2
8/16/2022 21:33,Referred,,Network Group 2,,,Network Group 1
8/16/2022 21:32,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 21:31,Referred,,Network Group 1,,,Central Team Office
8/16/2022 21:29,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 21:16,Referred,,Central Team Office,,,SOC Cable team
8/16/2022 21:15,Assigned,,SOC Cable team,,,SOC Cable team
8/16/2022 15:33,Referred,,SOC Cable team,,,Contractor Cable team
8/16/2022 15:29,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 15:27,Referred,,Central Team Office,,,Network Group 1
8/16/2022 15:26,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 15:25,Referred,,Network Group 1,,,Network Group 2
8/16/2022 15:07,Assigned,,Network Group 2,,,Network Group 2
8/16/2022 15:03,Referred,,Network Group 2,,,Network Group 1
8/16/2022 15:00,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 14:58,Referred,,Network Group 1,,,Central Team Office
8/16/2022 14:55,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 14:48,Referred,,Central Team Office,,,Network Group 1
8/16/2022 14:44,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 14:42,Referred,,Network Group 1,,,Network Group 2
8/16/2022 14:37,Assigned,,Network Group 2,,,Network Group 2
8/16/2022 14:31,Referred,,Network Group 2,,,Network Group 1
8/16/2022 14:29,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 14:28,Referred,,Network Group 1,,,Central Team Office
8/16/2022 14:26,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 14:20,Referred,,Central Team Office,,,SOC Cable team
8/16/2022 14:00,Assigned,,SOC Cable team,,,SOC Cable team
8/16/2022 4:36,Assigned,,SOC Cable team,,,SOC Cable team
8/16/2022 4:14,Referred,,SOC Cable team,,,Central Team Office
8/16/2022 4:04,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 4:02,Referred,,Central Team Office,,,View team
8/16/2022 4:00,Assigned,,Network Group 1,,,View team
8/16/2022 3:58,Referred,,Network Group 1,,,Central Team Office
8/16/2022 3:50,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 3:46,Referred,,Central Team Office,,,View team
8/16/2022 3:45,Assigned,,Network Group 1,,,View team
8/16/2022 3:43,Referred,,Network Group 1,,,Network Group 2
8/16/2022 3:42,Assigned,,Network Group 2,,,Network Group 2
8/16/2022 2:21,Referred,,Network Group 2,,,Network Group 1
8/16/2022 2:17,Assigned,,Network Group 1,,,Network Group 1
8/16/2022 2:16,Referred,,Network Group 1,,,Central Team Office
8/16/2022 2:15,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 2:14,Referred,,Central Team Office,,,Contractor Cable team
8/16/2022 1:10,Assigned,,Contractor Cable team,,,Contractor Cable team
8/16/2022 1:07,Referred,,Contractor Cable team,,,Central Team Office
8/16/2022 1:03,Assigned,,Central Team Office,,,Central Team Office
8/16/2022 1:03,Referred,,Central Team Office,,,SOC Cable team
8/16/2022 1:00,Assigned,,SOC Cable team,,,SOC Cable team
8/15/2022 20:30,Assigned,,SOC Cable team,,,SOC Cable team
8/15/2022 19:16,Referred,,SOC Cable team,,,Central Team Office
8/15/2022 18:55,Assigned,,Central Team Office,,,Central Team Office
8/15/2022 18:53,Assigned,,Central Team Office,,,Central Team Office
8/15/2022 18:40,Referred,,Central Team Office,,,SOC Cable team
8/14/2022 23:19,Assigned,,SOC Cable team,,,SOC Cable team
8/14/2022 23:07,Referred,,SOC Cable team,,,Central Team Office
8/14/2022 23:06,Assigned,,Central Team Office,,,Central Team Office
8/14/2022 23:03,Referred,,Central Team Office,,,Contractor Cable team
8/14/2022 23:01,Assigned,,Contractor Cable team,,,Contractor Cable team
8/14/2022 22:59,Referred,,Contractor Cable team,,,Central Team Office
1

There are 1 answers

0
Carsten Massmann On

A few questions are still unanswered (see comments under the question post) but from what I have understood so far the following might be a possible solution:

const [fields,...data]=Papa.parse(csv,{dynamicTyping: true}).data  // parse CSV data
 .map(([a,b,,c,,,d])=>[a,b,c,d]).filter(([,,a,b])=>a!=b) // see below!
 // - third, fifth and sixth columns are empty
 // - only keep entries with different "from" and "to" content

data.forEach(c=>c[0]=new Date(c[0])); // turn first column into date objects
data.sort(([a],[b])=>a-b);            // sort in ascending time order

let ldt=data[0][0],lteam=data[0][3];  // initialise "last dt" and "last team" variables
const times=data.reduce((a,[dt,,,team])=>{
 a[lteam] = (a[lteam]||0) + (dt-ldt)/1000; // accumulate the seconds
 [ldt,lteam]=[dt,team];
 return a;  // return the accumulator object
},{});

console.log("seconds spent in each department in the order of appearance:");
console.log(times);
console.log("times spent in each department ordered by duration in descending order:");
console.log(Object.entries(times).map(([team,time])=>[team,time,formatSecs(time)]).sort(([,a],[,b])=>b-a));

function formatSecs(n){
 let s,m0,m,h;
 n  -= (s=n%60);
 m0  = n/60
 m0 -= (m=m0%60);
 h   = m0/60
 return ((h?`${h}h`:"")+(m?` ${m}m`:"")+(s?` ${s}s`:"")).trim();
}
.as-console-wrapper {min-height:100%}
<table></table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js"></script>
<script>const csv="Action time,Status,RC,Referal Group,Assignee,User,User Group\n8/16/2022 21:39,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 21:39,Referred,,Network Group 1,,,Network Group 2\n8/16/2022 21:35,Assigned,,Network Group 2,,,Network Group 2\n8/16/2022 21:33,Referred,,Network Group 2,,,Network Group 1\n8/16/2022 21:32,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 21:31,Referred,,Network Group 1,,,Central Team Office\n8/16/2022 21:29,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 21:16,Referred,,Central Team Office,,,SOC Cable team\n8/16/2022 21:15,Assigned,,SOC Cable team,,,SOC Cable team\n8/16/2022 15:33,Referred,,SOC Cable team,,,Contractor Cable team\n8/16/2022 15:29,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 15:27,Referred,,Central Team Office,,,Network Group 1\n8/16/2022 15:26,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 15:25,Referred,,Network Group 1,,,Network Group 2\n8/16/2022 15:07,Assigned,,Network Group 2,,,Network Group 2\n8/16/2022 15:03,Referred,,Network Group 2,,,Network Group 1\n8/16/2022 15:00,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 14:58,Referred,,Network Group 1,,,Central Team Office\n8/16/2022 14:55,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 14:48,Referred,,Central Team Office,,,Network Group 1\n8/16/2022 14:44,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 14:42,Referred,,Network Group 1,,,Network Group 2\n8/16/2022 14:37,Assigned,,Network Group 2,,,Network Group 2\n8/16/2022 14:31,Referred,,Network Group 2,,,Network Group 1\n8/16/2022 14:29,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 14:28,Referred,,Network Group 1,,,Central Team Office\n8/16/2022 14:26,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 14:20,Referred,,Central Team Office,,,SOC Cable team\n8/16/2022 14:00,Assigned,,SOC Cable team,,,SOC Cable team\n8/16/2022 4:36,Assigned,,SOC Cable team,,,SOC Cable team\n8/16/2022 4:14,Referred,,SOC Cable team,,,Central Team Office\n8/16/2022 4:04,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 4:02,Referred,,Central Team Office,,,View team\n8/16/2022 4:00,Assigned,,Network Group 1,,,View team\n8/16/2022 3:58,Referred,,Network Group 1,,,Central Team Office\n8/16/2022 3:50,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 3:46,Referred,,Central Team Office,,,View team\n8/16/2022 3:45,Assigned,,Network Group 1,,,View team\n8/16/2022 3:43,Referred,,Network Group 1,,,Network Group 2\n8/16/2022 3:42,Assigned,,Network Group 2,,,Network Group 2\n8/16/2022 2:21,Referred,,Network Group 2,,,Network Group 1\n8/16/2022 2:17,Assigned,,Network Group 1,,,Network Group 1\n8/16/2022 2:16,Referred,,Network Group 1,,,Central Team Office\n8/16/2022 2:15,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 2:14,Referred,,Central Team Office,,,Contractor Cable team\n8/16/2022 1:10,Assigned,,Contractor Cable team,,,Contractor Cable team\n8/16/2022 1:07,Referred,,Contractor Cable team,,,Central Team Office\n8/16/2022 1:03,Assigned,,Central Team Office,,,Central Team Office\n8/16/2022 1:03,Referred,,Central Team Office,,,SOC Cable team\n8/16/2022 1:00,Assigned,,SOC Cable team,,,SOC Cable team\n8/15/2022 20:30,Assigned,,SOC Cable team,,,SOC Cable team\n8/15/2022 19:16,Referred,,SOC Cable team,,,Central Team Office\n8/15/2022 18:55,Assigned,,Central Team Office,,,Central Team Office\n8/15/2022 18:53,Assigned,,Central Team Office,,,Central Team Office\n8/15/2022 18:40,Referred,,Central Team Office,,,SOC Cable team\n8/14/2022 23:19,Assigned,,SOC Cable team,,,SOC Cable team\n8/14/2022 23:07,Referred,,SOC Cable team,,,Central Team Office\n8/14/2022 23:06,Assigned,,Central Team Office,,,Central Team Office\n8/14/2022 23:03,Referred,,Central Team Office,,,Contractor Cable team\n8/14/2022 23:01,Assigned,,Contractor Cable team,,,Contractor Cable team\n8/14/2022 22:59,Referred,,Contractor Cable team,,,Central Team Office";</script>

I have considered any "Referred" and "Assigned" entry as a signal that a new department is now processing the call and have then accumulated the times for each department accordingly.