<commit_before>var _ = require('underscore');

/**
 *  Control which analysis requires quota
 */

var unity = function (input) {
  return input;
};

var routingAnalysisQuota = {
  name: _t('editor.layers.analysis-form.quota.analysis-type.routing'),
  api: 'routing',
  user: 'mapzen_routing',
  needsQuota: true,
  transform: unity
};

var ANALYSES_WITH_QUOTA_MAP = {
  'trade-area': {
    name: _t('editor.layers.analysis-form.quota.analysis-type.trade-area'),
    api: 'isolines',
    user: 'here_isolines',
    transform: function (input, formModel) {
      // the isoline analysis consume N rows x M tracts
      return input * formModel.get('isolines');
    },
    needsQuota: function (quotaInfo) {
      var info = quotaInfo.getService('isolines');
      var provider = info && info.get('provider');
      return !!provider;
    }
  },
  'georeference-street-address': {
    name: _t('editor.layers.analysis-form.quota.analysis-type.georeference-street-address'),
    api: 'hires_geocoder',
    user: 'geocoding',
    transform: unity,
    needsQuota: true // we will include gmaps in the future
  },
  'data-observatory-measure': {
    name: _t('editor.layers.analysis-form.quota.analysis-type.data-observatory-measure'),
    api: 'observatory',
    user: 'obs_general',
    needsQuota: true,
    transform: function (input, formModel) {
      var measurements = formModel.get('measurements');
      var factor = measurements ? measurements.length : 1;
      // the data-observatory analysis consume N rows x M measurements
      return input * factor;
    }
  },
  'routing-sequential': routingAnalysisQuota,
  'routing-to-layer-all-to-all': routingAnalysisQuota,
  'routing-to-single-point': routingAnalysisQuota
};
<commit_msg>Applied quota restriction to do multiple.<commit_after>var _ = require('underscore');

/**
 *  Control which analysis requires quota
 */

var unity = function (input) {
  return input;
};

var routingAnalysisQuota = {
  name: _t('editor.layers.analysis-form.quota.analysis-type.routing'),
  api: 'routing',
  user: 'mapzen_routing',
  needsQuota: true,
  transform: unity
};

var dataObservatoryQuota = {
  name: _t('editor.layers.analysis-form.quota.analysis-type.data-observatory-measure'),
  api: 'observatory',
  user: 'obs_general',
  needsQuota: true,
  transform: unity
};

var ANALYSES_WITH_QUOTA_MAP = {
  'trade-area': {
    name: _t('editor.layers.analysis-form.quota.analysis-type.trade-area'),
    api: 'isolines',
    user: 'here_isolines',
    transform: function (input, formModel) {
      // the isoline analysis consume N rows x M tracts
      return input * formModel.get('isolines');
    },
    needsQuota: function (quotaInfo) {
      var info = quotaInfo.getService('isolines');
      var provider = info && info.get('provider');
      return !!provider;
    }
  },
  'georeference-street-address': {
    name: _t('editor.layers.analysis-form.quota.analysis-type.georeference-street-address'),
    api: 'hires_geocoder',
    user: 'geocoding',
    transform: unity,
    needsQuota: true // we will include gmaps in the future
  },
  'data-observatory-measure': dataObservatoryQuota,
  'data-observatory-multiple-measures': _.extend(dataObservatoryQuota, {
    transform: function (input, formModel) {
      var measurements = formModel.get('measurements');
      var factor = measurements ? measurements.length : 1;
      // the data-observatory analysis consume N rows x M measurements
      return input * factor;
    }
  }),
  'routing-sequential': routingAnalysisQuota,
  'routing-to-layer-all-to-all': routingAnalysisQuota,
  'routing-to-single-point': routingAnalysisQuota
};

{'fraction_non_alphanumeric': 0.13371773750686436, 'fraction_numerical': 0.0005491488193300384, 'mean_word_length': 3.6705128205128204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5457866', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1145, 'n_words': 250}