var spy_stream = require('through2-spy');
var _ = require('lodash');

var peliasModel = require( 'pelias-model' );
var peliasLogger = require( 'pelias-logger' );

/*
  This function performs the import based on the collection of WOF records
  gathered so far.  The parameters are:

  wof_record_stream: the base stream of WOF records to process
  document_generator: converts a WOF record to a Pelias Document
  destination_pipe: where the Pelias Document instances end up

*/
function fullImport(wof_record_stream, document_generator, destination_pipe, callback) {
  var logger = peliasLogger.get( 'whosonfirst', {
    transports: [
      new peliasLogger.winston.transports.File( {
        filename: 'missing_countries.log',
        timestamp: false
      })
    ]
  });

  var has_country_validation_stream = spy_stream.obj(function(wofDoc) {
    if (_.isUndefined(wofDoc.getAdmin('admin0'))) {
      logger.warn(wofDoc.getId());
    }
  });

  wof_record_stream
    .pipe(document_generator)
    .pipe(has_country_validation_stream)
    .pipe(peliasModel.createDocumentMapperStream())
    .pipe(destination_pipe)
    .on('finish', callback);

}

module.exports = fullImport;

@@ -1,161 +1,44 @@
 var 
-spy_stream = require('through2-spy');%0Avar _ = require('lodash');%0A%0Avar peliasModel = require( 'pelias-model' );%0Avar peliasLogger = require( 'pelias-logger
+peliasModel = require( 'pelias-model
 ' );
@@ -446,388 +446,8 @@
 ) %7B%0A
-  var logger = peliasLogger.get( 'whosonfirst', %7B%0A    transports: %5B%0A      new peliasLogger.winston.transports.File( %7B%0A        filename: 'missing_countries.log',%0A        timestamp: false%0A      %7D)%0A    %5D%0A  %7D);%0A%0A  var has_country_validation_stream = spy_stream.obj(function(wofDoc) %7B%0A    if (_.isUndefined(wofDoc.getAdmin('admin0'))) %7B%0A      logger.warn(wofDoc.getId());%0A    %7D%0A  %7D);%0A%0A
   wo
@@ -496,49 +496,8 @@
 or)%0A
-    .pipe(has_country_validation_stream)%0A
     

Remove validation stream