lib/js/app/stores/ExplorerStore.js
function _prepareUpdates(explorer, updates) {
  // TODO: We're assigning the response object directly onto the model so we
  // don't have to loop through the (sometimes) massive response object.
  function customizer(objValue, srcValue, key) {
    if (_.isArray(objValue)) {
      return srcValue;
    } else if (key === 'time' && _.isPlainObject(objValue)) {
      return srcValue;
    }
  }
  var newModel = _.mergeWith({}, explorer, _.omit(updates, 'response'), customizer);
  if (updates.response) newModel.response = updates.response;

  // Check if the event collection has changed. Clear the property names if so.
  if (updates.query && updates.query.event_collection && updates.query.event_collection !== explorer.query.event_collection) {
    newModel.query.property_names = [];
  }

  if(newModel.query.analysis_type === 'funnel' && explorer.query.analysis_type !== 'funnel') {
    newModel = _migrateToFunnel(explorer, newModel);
  } else if(newModel.query.analysis_type !== 'funnel' && explorer.query.analysis_type === 'funnel') {
    newModel = _migrateFromFunnel(explorer, newModel);
  }
  newModel = _removeInvalidFields(newModel);

  return newModel;
}
function _prepareUpdates(explorer, updates) {
  // TODO: We're assigning the response object directly onto the model so we
  // don't have to loop through the (sometimes) massive response object.
  function customizer(objValue, srcValue, key) {
    if (_.isArray(objValue)) {
      return srcValue;
    } else if (key === 'time' && _.isPlainObject(objValue)) {
      return srcValue;
    }
  }
  var newModel = _.mergeWith({}, explorer, _.omit(updates, 'response'), customizer);
  if (updates.response) newModel.response = updates.response;

  // Check if the event collection has changed. Clear the property names if so.
  if (updates.query && updates.query.event_collection && updates.query.event_collection !== explorer.query.event_collection) {
    newModel.query.property_names = [];
  }

  if(newModel.query.analysis_type === 'funnel' && explorer.query.analysis_type !== 'funnel') {
    newModel = _migrateToFunnel(explorer, newModel);
  } else if(newModel.query.analysis_type !== 'funnel' && explorer.query.analysis_type === 'funnel') {
    newModel = _migrateFromFunnel(explorer, newModel);
  }
  newModel = _removeInvalidFields(newModel);

  return newModel;
}
function _prepareUpdates ( explorer , updates ) { // TODO: We're assigning the response object directly onto the model so we // don't have to loop through the (sometimes) massive response object. function customizer ( objValue , srcValue , key ) { if ( _ . isArray ( objValue ) ) { return srcValue ; } else if ( key === 'time' && _ . isPlainObject ( objValue ) ) { return srcValue ; } } var newModel = _ . mergeWith ( { } , explorer , _ . omit ( updates , 'response' ) , customizer ) ; if ( updates . response ) newModel . response = updates . response ; // Check if the event collection has changed. Clear the property names if so. if ( updates . query && updates . query . event_collection && updates . query . event_collection !== explorer . query . event_collection ) { newModel . query . property_names = [ ] ; } if ( newModel . query . analysis_type === 'funnel' && explorer . query . analysis_type !== 'funnel' ) { newModel = _migrateToFunnel ( explorer , newModel ) ; } else if ( newModel . query . analysis_type !== 'funnel' && explorer . query . analysis_type === 'funnel' ) { newModel = _migrateFromFunnel ( explorer , newModel ) ; } newModel = _removeInvalidFields ( newModel ) ; return newModel ; }
Runs through the changeset and moves data around if necessary
@param {Object} explorer   The explorer model that is being updated
@param {Object} updates    The updated explorer model
@return {Object}           The new set of updates
Runs through the changeset and moves data around if necessary