<commit_before>var glimpse = require('glimpse');
var store = require('store.js');

var _storeSummaryKey = 'glimpse.data.summary.local',
_storeDetailKey = 'glimpse.data.request.local',
_storeDetailIndex = 'glimpse.data.request.local.index';

(function() {
  var storeSummary = store.get(_storeSummaryKey) || [];
  var storeDetail = store.get(_storeDetailKey) || {};
  function storeFoundSummary(data) {
    for (var i = 0; i < data.length; i++) {
      var request = data[i];
      storeSummary.unshift(request);
    }
    flush(storeSummary);
    store.set(_storeSummaryKey, storeSummary);
  }

  function flush(storeArray){
    while(storeArray.length > 100){
      var summary = storeArray.pop();
    }
  }

  glimpse.on('data.request.summary.found.remote', storeFoundSummary);
  glimpse.on('data.request.summary.found.stream', storeFoundSummary);
})();

(function() {

  function storeFoundDetail(data) {
    var storeDetail = store.get(_storeDetailKey) || {};
    var storeDetailIndex = store.get(_storeDetailIndex) || [];
    storeDetail[data.id] = data;
    storeDetailIndex.unshift(data.id);

    if(storeDetailIndex.length > 10){
      var id = storeDetailsIndex.pop();
      delete storeDetail[id];
    }

    store.set(_storeDetailKey, storeDetail);
    store.set(_storeDetailIndex, storeDetailIndex)
  }

  glimpse.on('data.request.detail.found.remote', storeFoundDetail);
})();

module.exports = {
  triggerGetLastestSummaries: function() {
    var data = store.get(_storeSummaryKey);
    if(data){
      glimpse.emit('data.request.summary.found.local', data);
    }
  },
  triggerGetDetailsFor: function(requestId) {
    var data = store.get(_storeDetailKey);
    if(data){
      var requestDetail = data[requestId];
      if(requestDetail){
        glimpse.emit('data.request.detail.found.local', requestDetail);
      }
    }
  }

};<commit_msg>Flush details extracrted to method. Spacing changes<commit_after>var glimpse = require('glimpse');
var store = require('store.js');

var _storeSummaryKey = 'glimpse.data.summary.local',
_storeDetailKey = 'glimpse.data.request.local',
_storeDetailIndex = 'glimpse.data.request.local.index';

(function() {
   var storeSummary;

   function storeFoundSummary(data) {
      storeSummary = store.get(_storeSummaryKey) || [];
      for (var i = 0; i < data.length; i++) {
         var request = data[i];
         storeSummary.unshift(request);
      }
      flush();
      store.set(_storeSummaryKey, storeSummary);
   }

   function flush(){
      while(storeSummary.length > 100){
         storeSummary.pop();
      }
   }

   glimpse.on('data.request.summary.found.remote', storeFoundSummary);
   glimpse.on('data.request.summary.found.stream', storeFoundSummary);
})();

(function() {
   var storeDetail, storeDetailIndex;

   function storeFoundDetail(data) {
      storeDetail = store.get(_storeDetailKey) || {};
      storeDetailIndex = store.get(_storeDetailIndex) || [];
      storeDetail[data.id] = data;
      storeDetailIndex.unshift(data.id);
      flush();
      store.set(_storeDetailKey, storeDetail);
      store.set(_storeDetailIndex, storeDetailIndex)
   }

   function flush(){
      while(storeDetailIndex.length > 10){
         var id = storeDetailsIndex.pop();
         delete storeDetail[id];
      }
   }

   glimpse.on('data.request.detail.found.remote', storeFoundDetail);
})();

module.exports = {
   triggerGetLastestSummaries: function() {
      var data = store.get(_storeSummaryKey);
      if(data){
         glimpse.emit('data.request.summary.found.local', data);
      }
   },
   triggerGetDetailsFor: function(requestId) {
      var data = store.get(_storeDetailKey);
      if(data){
         var requestDetail = data[requestId];
         if(requestDetail){
            glimpse.emit('data.request.detail.found.local', requestDetail);
         }
      }
   }

};
{'fraction_non_alphanumeric': 0.14152168267982343, 'fraction_numerical': 0.003116073747078681, 'mean_word_length': 3.4275862068965517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3132849', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1201, 'n_words': 192}