<commit_before>var cdb = require('cartodb.js');
var BackgroundPollingModel = require('../common/background_polling/background_polling_model');

/**
 *  Background polling model for the dashboard context.
 */

module.exports = BackgroundPollingModel.extend({

  _onImportsStateChange: function(importsModel) {
    // Redirect to dataset/map url?
    if (!this.get('importLimit') &&
        ( this.importsCollection.size() - this.importsCollection.failedItems().length ) === 1 &&
        importsModel.get('state') === 'complete' &&
        importsModel.imp.get('tables_created_count') === 1 &&
        importsModel.imp.get('service_name') !== 'twitter_search') {
      var vis = importsModel.importedVis();
      if (vis) {
        this._redirectTo(encodeURI(vis.viewUrl(this.user).edit()));
      }
    }
  },

  _redirectTo: function(url) {
    window.location = url;
  }

});
<commit_msg>Adding trigger when import is completed<commit_after>var cdb = require('cartodb.js');
var BackgroundPollingModel = require('../common/background_polling/background_polling_model');

/**
 *  Background polling model for the dashboard context.
 */

module.exports = BackgroundPollingModel.extend({

  _onImportsStateChange: function(importsModel) {
    // Redirect to dataset/map url?
    if (( this.importsCollection.size() - this.importsCollection.failedItems().length ) === 1 &&
        importsModel.hasCompleted() &&
        importsModel.imp.get('tables_created_count') === 1 &&
        importsModel.imp.get('service_name') !== 'twitter_search') {
      var vis = importsModel.importedVis();
      if (vis) {
        this._redirectTo(encodeURI(vis.viewUrl(this.user).edit()));
        return;
      }
    }

    if (importsModel.hasCompleted()) {
      this.trigger('importCompleted', importsModel, this);
    }
  },

  _redirectTo: function(url) {
    window.location = url;
  }

});

{'fraction_non_alphanumeric': 0.14872068230277186, 'fraction_numerical': 0.0021321961620469083, 'mean_word_length': 3.5558252427184467, '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': '6648139', 'n_tokens_mistral': 571, 'n_tokens_neox': 556, 'n_words': 93}