function filterDuplicateRecordedPairs(service){

  //This check probably looks excessive- it is necessary because service can be null, the live invo group can be null, the recorded section can be null, and recorded can be 0 length! 
  //Not checking makes the entire app grind to a half if any of those are null. 
  if(service && service.liveInvocation && service.liveInvocation.recordedRRPairs && service.liveInvocation.recordedRRPairs.length){
    var pairs = service.liveInvocation.recordedRRPairs;
    var keepThisRRPair = [];
    var strippedPairs = [];
    for(let i = 0; i < pairs.length; i++){
      keepThisRRPair.push(true);
      strippedPairs[i] = stripRRPair(pairs[i]);
    }

    //iterate over all RR pairs, calling them i. 
    for(let i = 0; i < strippedPairs.length; i++){

      //If i has not already been eliminated...
      if(keepThisRRPair[i]){

        //Then compare it against all RRPairs further down the list than i, calling each one j
        for(let j = i+1; j < strippedPairs.length;j++){

          //If i and j are duplicates, mark off j (but not i) to NOT include in the trimmed list. 
          if(deepEquals(strippedPairs[i],strippedPairs[j])){
            keepThisRRPair[j] = false;
          }
        }
      }
    }
    //Extract only the rrpairs we want to
    var rrPairs = [];
    for(let i = 0; i < pairs.length; i++){
      if(keepThisRRPair[i]){
        rrPairs.push(pairs[i]);
      }
    }
    rrPairs = rrPairs.slice(-10);
    //if changes were made, save them
    if(rrPairs.length != pairs.length){
      service.liveInvocation.recordedRRPairs = rrPairs;
      logEvent("","Mongoose","Saving modified pairs. Old count:" + pairs.length  + " New count: " + rrPairs.length);
      service.save(function(err){
        logEvent("","Mongoose",err);
      });
    }

  }
  
  return service;
}
/**
 * Goes through liveinvocation.recordedRRPairs and strips out all duplicates before saving the service
 * @param {Service} service 
 */
Goes through liveinvocation.recordedRRPairs and strips out all duplicates before saving the service
@param {Service} service
Goes through liveinvocation . recordedRRPairs and strips out all duplicates before saving the service @param { Service } service
function filterDuplicateRecordedPairs(service){
  if(service && service.liveInvocation && service.liveInvocation.recordedRRPairs && service.liveInvocation.recordedRRPairs.length){
    var pairs = service.liveInvocation.recordedRRPairs;
    var keepThisRRPair = [];
    var strippedPairs = [];
    for(let i = 0; i < pairs.length; i++){
      keepThisRRPair.push(true);
      strippedPairs[i] = stripRRPair(pairs[i]);
    }
    for(let i = 0; i < strippedPairs.length; i++){
      if(keepThisRRPair[i]){
        for(let j = i+1; j < strippedPairs.length;j++){
          if(deepEquals(strippedPairs[i],strippedPairs[j])){
            keepThisRRPair[j] = false;
          }
        }
      }
    }
    var rrPairs = [];
    for(let i = 0; i < pairs.length; i++){
      if(keepThisRRPair[i]){
        rrPairs.push(pairs[i]);
      }
    }
    rrPairs = rrPairs.slice(-10);
    if(rrPairs.length != pairs.length){
      service.liveInvocation.recordedRRPairs = rrPairs;
      logEvent("","Mongoose","Saving modified pairs. Old count:" + pairs.length  + " New count: " + rrPairs.length);
      service.save(function(err){
        logEvent("","Mongoose",err);
      });
    }
  }
  return service;
}
function filterDuplicateRecordedPairs ( service ) { if ( service && service . liveInvocation && service . liveInvocation . recordedRRPairs && service . liveInvocation . recordedRRPairs . length ) { var pairs = service . liveInvocation . recordedRRPairs ; var keepThisRRPair = [ ] ; var strippedPairs = [ ] ; for ( let i = 0 ; i < pairs . length ; i ++ ) { keepThisRRPair . push ( true ) ; strippedPairs [ i ] = stripRRPair ( pairs [ i ] ) ; } for ( let i = 0 ; i < strippedPairs . length ; i ++ ) { if ( keepThisRRPair [ i ] ) { for ( let j = i + 1 ; j < strippedPairs . length ; j ++ ) { if ( deepEquals ( strippedPairs [ i ] , strippedPairs [ j ] ) ) { keepThisRRPair [ j ] = false ; } } } } var rrPairs = [ ] ; for ( let i = 0 ; i < pairs . length ; i ++ ) { if ( keepThisRRPair [ i ] ) { rrPairs . push ( pairs [ i ] ) ; } } rrPairs = rrPairs . slice ( - 10 ) ; if ( rrPairs . length != pairs . length ) { service . liveInvocation . recordedRRPairs = rrPairs ; logEvent ( "" , "Mongoose" , "Saving modified pairs. Old count:" + pairs . length + " New count: " + rrPairs . length ) ; service . save ( function ( err ) { logEvent ( "" , "Mongoose" , err ) ; } ) ; } } return service ; }
Goes through liveinvocation.recordedRRPairs and strips out all duplicates before saving the service
 @param {Service} service
Goes through liveinvocation . recordedRRPairs and strips out all duplicates before saving the service @param { Service } service
//This check probably looks excessive- it is necessary because service can be null, the live invo group can be null, the recorded section can be null, and recorded can be 0 length!  //Not checking makes the entire app grind to a half if any of those are null.  //iterate over all RR pairs, calling them i.  //If i has not already been eliminated... //Then compare it against all RRPairs further down the list than i, calling each one j //If i and j are duplicates, mark off j (but not i) to NOT include in the trimmed list.  //Extract only the rrpairs we want to //if changes were made, save them