<commit_before>'use strict';

var controllersModule = require('./_index');
var PhotoSwipe = require('photoswipe');
var PhotoSwipeUI_Default = require('../components/photoswipe-ui-default');
/**
 * @ngInject
 */
function SearchCtrl($stateParams, $timeout, $location, $http, AppSettings, SearchService) {
    var vm = this;

    // Init statues if path is a search url
    angular.element(document).ready(function() {
        console.log($stateParams);
        console.log($stateParams.timezoneOffset);
         SearchService.initData($stateParams)
            .then(function(data) {
              vm.statuses = data.statuses;
            },
            function() {
              console.log('statuses init retrieval failed');
            });   
    });

    // Change stateParams on search
    function updatePath(term) {
      $location.search({
        q: encodeURIComponent(term), 
        timezoneOffset: (new Date()).getTimezoneOffset()
      });
    }

    // Update status and path on success search
    vm.update = function(term) {
        SearchService.getData(term)
            .then(function(data) {<commit_msg>Fix init search on undefined term<commit_after>'use strict';

var controllersModule = require('./_index');
var PhotoSwipe = require('photoswipe');
var PhotoSwipeUI_Default = require('../components/photoswipe-ui-default');
/**
 * @ngInject
 */
function SearchCtrl($stateParams, $timeout, $location, $http, AppSettings, SearchService) {
    var vm = this;

    // Init statues if path is a search url
    angular.element(document).ready(function() {
      if ($stateParams.q !== undefined) {
          SearchService.initData($stateParams)
             .then(function(data) {
               vm.statuses = data.statuses;
             },
             function() {
               console.log('statuses init retrieval failed');
             });   
      }
    });

    // Change stateParams on search
    function updatePath(term) {
      $location.search({
        q: encodeURIComponent(term), 
        timezoneOffset: (new Date()).getTimezoneOffset()
      });
    }

    // Update status and path on success search
    vm.update = function(term) {
        SearchService.getData(term)
            .then(function(data) {
{'fraction_non_alphanumeric': 0.12790697674418605, 'fraction_numerical': 0.0, 'mean_word_length': 2.5007824726134587, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2823860', 'n_tokens_mistral': 611, 'n_tokens_neox': 600, 'n_words': 136}