<commit_before>jasmine.FHReporter = function(){
  var self = this;

  var fh = window.$fh;
  var guid = (function() {
    function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
                 .toString(16)
                 .substring(1);
    }
    return function() {
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
             s4() + '-' + s4() + s4() + s4();
    };
  })();

  var reporterId = guid();

  var reportsCache = [];
  var limit = 10;

  function sendReport(testData){
    testData.ts = new Date().getTime();
    reportsCache.push(testData);
    if(reportsCache.length === limit){
      var dataToSend = reportsCache.splice(0, limit);
      var reqData = {};
      reqData.reporterId = reporterId;
      reqData.deviceInfo = window.device || {};
      reqData.testInfo = dataToSend;
      fh.cloud({
        path: '/recordTest',
        type: 'POST',
        contentType: 'application/json',
        data: reqData
      }, function(res){
        self.log('[FHReporter] Update success');
      }, function(msg, err){
        self.log('[FHReporter] Update failed - ' + msg);
      });
    }
  };

  self.log = function(){
    var console = jasmine.getGlobal().console;
    if (console && console.log) {
      if (console.log.apply) {
        console.log.apply(console, arguments);
      } else {
        console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
      }
    }
  };

  self.reportRunnerStarting = function(runner){
    var specs = runner.specs() || [];
    sendReport({
      stage: 'runner_starting',
      data: {
        'total_specs': specs.length
      }
    });
  };

  self.reportRunnerResults = function(runner){
    var results = suite.results();
    var passed = results.passed();
    var totalCount = results.totalCount;
    var passedCount = results.passedCount;
    var failedCount = results.failedCount;
    sendReport({
      stage: 'complete',
      data: {
        'total': totalCount,
        'passedCount': passedCount,
        'failedCount': failedCount,
        'passed': passed
      }
    });
  };

  self.reportSuiteResults = function(suite){
    var suiteId = suite.id;
    var fullName = suite.getFullName();
    var results = suite.results();
    var passed = results.passed();
    var totalCount = results.totalCount;
    var passedCount = results.passedCount;
    var failedCount = results.failedCount;
    var skipped = results.skipped;
    sendReport({
      stage: 'suite_complete',
      data: {
        suiteId: suiteId,
        name: fullName,
        passed: passed,
        totalCount: totalCount,
        passedCount: passedCount,
        failedCount: failedCount,
        skipped : skipped
      }
    });
  };

  self.reportSpecStarting = function(spec){

  };

  self.reportSpecResults = function(spec){
    var results = spec.results();
    var passed = results.passed();
    if(!passed){
      var fullName = spec.getFullName();
      var desc = spec.description;
      var resultItems = results.getItems();
      var resultData = [];
      for(var i=0;i<resultItems.length;i++){<commit_msg>add progress<commit_after>jasmine.FHReporter = function(){
  var self = this;

  var fh = window.$fh;
  var guid = (function() {
    function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
                 .toString(16)
                 .substring(1);
    }
    return function() {
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
             s4() + '-' + s4() + s4() + s4();
    };
  })();

  var reporterId = guid();

  var reportsCache = [];
  var limit = 10;
  var totalSpecs, specCounter;

  function sendReport(testData){
    testData.ts = new Date().getTime();
    testData.progress = {
      total: totalSpecs,
      run: specCounter
    };
    reportsCache.push(testData);
    if(reportsCache.length === limit){
      var dataToSend = reportsCache.splice(0, limit);
      var reqData = {};
      reqData.reporterId = reporterId;
      reqData.deviceInfo = window.device || {};
      reqData.testInfo = dataToSend;
      fh.cloud({
        path: '/recordTest',
        type: 'POST',
        contentType: 'application/json',
        data: reqData
      }, function(res){
        self.log('[FHReporter] Update success');
      }, function(msg, err){
        self.log('[FHReporter] Update failed - ' + msg);
      });
    }
  };

  self.log = function(){
    var console = jasmine.getGlobal().console;
    if (console && console.log) {
      if (console.log.apply) {
        console.log.apply(console, arguments);
      } else {
        console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
      }
    }
  };

  self.reportRunnerStarting = function(runner){
    var specs = runner.specs() || [];
    totalSpecs = specs.length;
    sendReport({
      stage: 'runner_starting'
    });
  };

  self.reportRunnerResults = function(runner){
    var results = suite.results();
    var passed = results.passed();
    var totalCount = results.totalCount;
    var passedCount = results.passedCount;
    var failedCount = results.failedCount;
    sendReport({
      stage: 'complete',
      data: {
        'total': totalCount,
        'passedCount': passedCount,
        'failedCount': failedCount,
        'passed': passed
      }
    });
  };

  self.reportSuiteResults = function(suite){
    var suiteId = suite.id;
    var fullName = suite.getFullName();
    var results = suite.results();
    var passed = results.passed();
    var totalCount = results.totalCount;
    var passedCount = results.passedCount;
    var failedCount = results.failedCount;
    var skipped = results.skipped;
    sendReport({
      stage: 'suite_complete',
      data: {
        suiteId: suiteId,
        name: fullName,
        passed: passed,
        totalCount: totalCount,
        passedCount: passedCount,
        failedCount: failedCount,
        skipped : skipped
      }
    });
  };

  self.reportSpecStarting = function(spec){
    specCounter++;
  };

  self.reportSpecResults = function(spec){
    var results = spec.results();
    var passed = results.passed();
    if(!passed){
      var fullName = spec.getFullName();
      var desc = spec.description;
      var resultItems = results.getItems();
      var resultData = [];
      for(var i=0;i<resultItems.length;i++){
{'fraction_non_alphanumeric': 0.14165742354618918, 'fraction_numerical': 0.007288860719378862, 'mean_word_length': 2.343220338983051, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '103352', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1878, 'n_words': 420}