@@ -165,21 +165,23 @@ module.exports = Schema.extend({
165165 }
166166 model . documents . reset ( docs ) ;
167167 model . documents . trigger ( 'sync' ) ;
168+ app . statusbar . hide ( true ) ;
168169
169170 // @note (imlucas): Any other metrics? Feedback on `Schema *`?
170171 var totalTime = new Date ( ) - start ;
171172 var timeToFirstDoc = timeAtFirstDoc - start ;
172173
173174 metrics . track ( 'Schema: Complete' , {
174- Duration : totalTime ,
175- 'Total Document Count' : model . total ,
176- 'Sample Size' : model . documents . length ,
177- 'Errored Document Count' : erroredOnDocs . length ,
178- 'Time to First Doc' : timeToFirstDoc ,
179- 'Average Time Per Doc' : ( totalTime - timeToFirstDoc ) / model . documents . length
180- // 'Schema Height': model.height, // # of top level keys
181- // 'Schema Width': model.width, // max nesting depth
182- // 'Schema Sparsity': model.sparsity // lots of fields missing or consistent
175+ duration : totalTime ,
176+ 'total document count' : model . total ,
177+ 'sample size' : model . documents . length ,
178+ 'errored document count' : erroredOnDocs . length ,
179+ 'total sample time' : timeToFirstDoc ,
180+ 'total analysis time' : totalTime - timeToFirstDoc ,
181+ 'average analysis time per doc' : ( totalTime - timeToFirstDoc ) / model . documents . length
182+ // 'Schema Height': model.height, // # of top level keys
183+ // 'Schema Width': model.width, // max nesting depth
184+ // 'Schema Sparsity': model.sparsity // lots of fields missing or consistent
183185 } ) ;
184186 options . success ( { } ) ;
185187 } ;
@@ -199,9 +201,29 @@ module.exports = Schema.extend({
199201 return onEmpty ( ) ;
200202 }
201203
202- debug ( 'creating sample stream' ) ;
204+ var status = 0 ;
205+ var counter = 0 ;
206+ var numSamples = Math . min ( options . size , count . count ) ;
207+ var stepSize = Math . ceil ( Math . max ( 1 , numSamples / 10 ) ) ;
208+
209+ app . statusbar . show ( 'Sampling collection...' ) ;
210+ app . statusbar . width = 1 ;
211+ app . statusbar . trickle ( true ) ;
203212 app . client . sample ( model . ns , options )
204213 . pipe ( es . map ( parse ) )
214+ . once ( 'data' , function ( ) {
215+ status = app . statusbar . width ;
216+ app . statusbar . message = 'Analyzing documents...' ;
217+ app . statusbar . trickle ( false ) ;
218+ } )
219+ . on ( 'data' , function ( ) {
220+ counter ++ ;
221+ if ( counter % stepSize === 0 ) {
222+ var inc = ( 100 - status ) * stepSize / numSamples ;
223+ debug ( inc ) ;
224+ app . statusbar . width += inc ;
225+ }
226+ } )
205227 . pipe ( es . map ( addToDocuments ) )
206228 . pipe ( es . wait ( onEnd ) ) ;
207229 } ) ;
0 commit comments