11'use strict' ;
22
33angular . module ( 'codeSearchApp' )
4- . factory ( 'apiRequest' , function ( $http , $timeout , codeParser ) {
4+ . factory ( 'apiRequest' , function ( $http , $rootScope , $ timeout, codeParser ) {
55 var apiRequest = { } ;
66
77 var searchOptions ;
88 var searchQuery ;
99 var library = "" ;
1010 var libFunction = "" ;
1111
12+ var maxFiles = 500 ;
13+
1214 var getDepVar = function ( lib , file ) {
1315 var parsedData = esprima . tokenize ( file ) ;
1416
@@ -66,6 +68,10 @@ angular.module('codeSearchApp')
6668 } ;
6769
6870 apiRequest . findCode = function ( lib , func ) {
71+ $timeout ( function ( ) {
72+ $rootScope . statusMsg . msg = "Parsing through files for example snippets..." ;
73+ } , 3000 ) ;
74+
6975 return $http ( {
7076 method :'GET' ,
7177 url :'/api/findFile' ,
@@ -75,6 +81,7 @@ angular.module('codeSearchApp')
7581 }
7682 } )
7783 . then ( function ( data ) {
84+
7885 searchOptions = data . data . searchOptions ;
7986 searchQuery = data . data . searchQuery ;
8087 library = lib ;
@@ -85,6 +92,7 @@ angular.module('codeSearchApp')
8592 console . log ( 'files' , allFiles [ 0 ] . score ) ;
8693 console . log ( 'sOpts' , searchOptions ) ;
8794 console . log ( 'sQuer' , searchQuery ) ;
95+ // console.log($rootScope.statusMsg.msg);
8896
8997 allFiles . sort ( function ( a , b ) {
9098 if ( a . score < b . score ) {
@@ -98,7 +106,7 @@ angular.module('codeSearchApp')
98106
99107 console . log ( 'files' , allFiles [ 0 ] . score ) ;
100108
101- var end = allFiles . length <= 1800 ? allFiles . length : 1800 ;
109+ var end = allFiles . length <= maxFiles ? allFiles . length : maxFiles ;
102110
103111 var files = allFiles . slice ( 0 , end ) ;
104112
@@ -121,6 +129,7 @@ angular.module('codeSearchApp')
121129 return [ snippitsArray , snippitPaths ] ;
122130 } )
123131 . then ( function ( results ) {
132+
124133 return $http . post ( '/api/popSnips' ,
125134 { data : results [ 1 ] } )
126135 . then ( function ( data ) {
0 commit comments