updateData function

Future updateData(
  1. Node? metricNode
)

Update risk score as latest Refer latest metrics from external plugins

Implementation

Future updateData(Node? metricNode) async{

  try {

      ///split entire path using ':'
      ///':~:~:~:....'
      ///path List [0] => ''
      ///path LIst [1] => Users or Devices etc.
      ///...
      var pathList = metricNode!.path.toString().split(':');

      var type = '';
      var nodePath = '';
      var nodeName = '';


      ///Set metrics type, path and name
      if(pathList[1] == Types.users){
        type =Types.users;
        nodePath = Types.userScoreNodePath;
        nodeName = Types.geigerScoreUser;
      }else{

        type =Types.devices;
        nodePath = Types.deviceScoreNodePath;
        nodeName =Types.geigerScoreDevice;
      }

      ///Check metric value (GEIGERvalue) whether exist or not
      if((await metricNode.getValue('GEIGERvalue')) != null) {

        //await clearPN();

        await updateMetrics(type, metricNode);
        await updateScoreNode(nodePath,nodeName,type);
        await updateRecommendationNode(nodePath,Types.recommendations,type);
        await aggregateScore();

      }else{
        logger.i('updateMetrics $metricNode GEIGERvalue is not existed');
        return;
      }

  }catch(e){
    logger.e(e);

  }

}