<commit_before>var cdb = require('cartodb.js');

/**
 * Intermediate model to create a formula widget definition.
 */
module.exports = cdb.core.Model.extend({

  defaults: {
    layer_index: 0,
    operation: 'avg',
    bucket: []
  },

  createWidgetDefinitionModel: function (widgetDefinitionsCollection) {
    var i = this.get('layer_index');
    var item = this.get('bucket')[i];
    var columnName = item.columnModel.get('name');
    var operation = this.get('operation');

    widgetDefinitionsCollection.create({
      type: 'formula',
      title: columnName + ' ' + operation.toUpperCase(), // e.g. 'some_numbers AVG'
      layer_id: item.layerDefinitionModel.id,
      options: {
        column: columnName,
        operation: operation
      }
    }, {
      wait: true // until API confirms it was created
    });
  }
});
<commit_msg>Fix widget creation<commit_after>var cdb = require('cartodb.js');

/**
 * Intermediate model to create a formula widget definition.
 */
module.exports = cdb.core.Model.extend({

  defaults: {
    layer_index: 0,
    operation: 'avg',
    bucket: []
  },

  createWidgetDefinitionModel: function (widgetDefinitionsCollection) {
    var i = this.get('layer_index');
    var item = this.get('bucket')[i];
    var columnName = item.columnModel.get('name');
    var operation = this.get('operation');

    widgetDefinitionsCollection.create({
      type: 'formula',
      title: columnName + ' ' + operation.toUpperCase(), // e.g. 'some_numbers AVG'
      layer_id: item.layerDefinitionModel.id,
      column: columnName,
      operation: operation
    }, {
      wait: true // until API confirms it was created
    });
  }
});

{'fraction_non_alphanumeric': 0.1384062312762133, 'fraction_numerical': 0.0011983223487118035, 'mean_word_length': 3.073170731707317, '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': '4632366', 'n_tokens_mistral': 511, 'n_tokens_neox': 488, 'n_words': 117}