@@ -165,21 +165,23 @@ module.exports = Schema.extend({
165
165
}
166
166
model . documents . reset ( docs ) ;
167
167
model . documents . trigger ( 'sync' ) ;
168
+ app . statusbar . hide ( true ) ;
168
169
169
170
// @note (imlucas): Any other metrics? Feedback on `Schema *`?
170
171
var totalTime = new Date ( ) - start ;
171
172
var timeToFirstDoc = timeAtFirstDoc - start ;
172
173
173
174
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
183
185
} ) ;
184
186
options . success ( { } ) ;
185
187
} ;
@@ -199,9 +201,29 @@ module.exports = Schema.extend({
199
201
return onEmpty ( ) ;
200
202
}
201
203
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 ) ;
203
212
app . client . sample ( model . ns , options )
204
213
. 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
+ } )
205
227
. pipe ( es . map ( addToDocuments ) )
206
228
. pipe ( es . wait ( onEnd ) ) ;
207
229
} ) ;
0 commit comments