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

LayerGroupConfig.generate = function (options) {
  var layers = options.layers;
  var dataviews = options.dataviews;
  var config = { layers: [] };
  _.each(layers, function (layer) {
    if (layer.isVisible()) {
      var layerConfig = {
        type: layer.get('type').toLowerCase(),
        options: {
          sql: layer.get('sql'),
          cartocss: layer.get('cartocss'),
          cartocss_version: layer.get('cartocss_version'),
          interactivity: layer.getInteractiveColumnNames(),
          // TODO widgets should be renamed to dataviews, requires Windshaft to be changed first though
          widgets: {}
        }
      };

      if (dataviews) {
        layerConfig.options.widgets = dataviews.reduce(function (memo, m) {
          if (layer.get('id') === m.layer.get('id')) {
            memo[m.get('id')] = m.toJSON();
          }
          return memo;
        }, {});
      }
<commit_msg>Set the default cartoCSS version when generating the MapConfig<commit_after>var _ = require('underscore');
var LayerGroupConfig = {};

var DEFAULT_CARTOCSS_VERSION = '2.1.0';

LayerGroupConfig.generate = function (options) {
  var layers = options.layers;
  var dataviews = options.dataviews;
  var config = { layers: [] };
  _.each(layers, function (layer) {
    if (layer.isVisible()) {
      var layerConfig = {
        type: layer.get('type').toLowerCase(),
        options: {
          sql: layer.get('sql'),
          cartocss: layer.get('cartocss'),
          cartocss_version: layer.get('cartocss_version') || DEFAULT_CARTOCSS_VERSION,
          interactivity: layer.getInteractiveColumnNames(),
          // TODO widgets should be renamed to dataviews, requires Windshaft to be changed first though
          widgets: {}
        }
      };

      if (dataviews) {
        layerConfig.options.widgets = dataviews.reduce(function (memo, m) {
          if (layer.get('id') === m.layer.get('id')) {
            memo[m.get('id')] = m.toJSON();
          }
          return memo;
        }, {});
      }

{'fraction_non_alphanumeric': 0.13931297709923665, 'fraction_numerical': 0.0014312977099236641, 'mean_word_length': 2.4603960396039604, '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': '5697042', 'n_tokens_mistral': 639, 'n_tokens_neox': 634, 'n_words': 136}