<commit_before>window.App.controller('SearchController', function($scope) {

  $scope.query = '';
  $scope.results = [];

  var loaded_data;
  var idx = lunr(function () {
    this.field('id');
    this.field('title', { boost: 10 });
    this.field('keywords');
    this.field('category');
  });

  var data = $.getJSON('/search_data.json');
  data.then(function(_data){
    loaded_data = _data;
    $.each(loaded_data, function(index, value){
      idx.add(
        $.extend({ "id": index }, value)
      );
    });
  });

  $scope.$watch('query', function() {
    var items = idx.search($scope.query);
    var res = [];
    items.forEach(function(item) {
      res.push(loaded_data[item.ref]);
    });
    $scope.results = res;
  });

  $scope.$watch('results', function() {
    console.log($scope.results);
  });

});


jQuery(function() {


  function display_search_results(results) {
    var $search_results = $("#search_results");

    // Wait for data to load
    window.data.then(function(loaded_data) {

      // Are there any results?
      if (results.length) {
        $search_results.empty(); // Clear any old results

        // Iterate over the results
        results.forEach(function(result) {
          var item = loaded_data[result.ref];
          console.log(item);

          // Build a snippet of HTML for this result
          var appendString = '<li><a href="' + item.url + '">' + item.title + '</a></li>';

          // Add it to the results
          $search_results.append(appendString);
        });
      } else {
        $search_results.html('<li>No results found</li>');
      }
    });
  }
});<commit_msg>Site updated at 2015-09-10 18:41:25 UTC<commit_after>window.App.controller('SearchController', function($scope) {

  $scope.query = '';
  $scope.results = [];

  var loaded_data;
  var idx = lunr(function () {
    this.field('id');
    this.field('title', { boost: 10 });
    this.field('keywords');
    this.field('category');
  });

  var data = $.getJSON('/search_data.json');
  data.then(function(_data){
    loaded_data = _data;
    $.each(loaded_data, function(index, value){
      idx.add(
        $.extend({ "id": index }, value)
      );
    });
  });

  $scope.$watch('query', function() {
    var items = idx.search($scope.query);
    var res = [];
    items.forEach(function(item) {
      res.push(loaded_data[item.ref]);
    });
    $scope.results = res;
  });

  $scope.$watch('results', function() {
    console.log($scope.results);
  });

});
{'fraction_non_alphanumeric': 0.18557114228456914, 'fraction_numerical': 0.007214428857715431, 'mean_word_length': 2.6923076923076925, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '6569269', 'n_tokens_mistral': 816, 'n_tokens_neox': 779, 'n_words': 148}