<commit_before>
  /**
   *  Background geocoder now extends from
   *  background importer
   */

  cdb.admin.BackgroundGeocoder = cdb.core.View.extend({

    events: {
      'click a.cancel': '_showCancel'
    },

    className: "background_importer",

    initialize: function() {
      _.bindAll(this, "show", "hide", "changeState");

      // Dropdown template
      this.template_base = cdb.templates.getTemplate(this.options.template_base);
    },

    render: function() {
      var content = this.template_base(this.model.toJSON());
      this.$el.html(content);

      //HACK: change this or test it
      if (content.length > 50) {
        this.$el.stop()
          .css({opacity: 1})
          .animate({
            bottom: "0px"
          }, 500);

        this.delegateEvents();
      }
      
      return this;
    },

    // when the importer is a geocoder bind its stats
    bindGeocoder: function() {
      var self = this;

      this.model.bind('geocodingStarted', function() {
        self.changeState();
        self._showProgress();
      }, this);

      this.model.bind('geocodingChange', function() {
        self._setProgress();
      }, this);

      this.model.bind('geocodingReset geocodingComplete geocodingFailed', function() {
        self.hide();
      }, this);

      this.bind('canceled', function() {
        self.model.trigger('geocodingCanceled');
      });
    },

    // Show progress but don't render again
    // the whole component
    _setProgress: function() {
      var attrs = this.model.toJSON();
      this.$('label.count').text(attrs.processed_rows + "/" + attrs.total_rows);
    },

    // Show progress bar
    _showProgress: function() {
      this.$el
        .css({opacity: 1})
        .animate({
          bottom: "0px"
        }, 500);
    },

    changeState: function() {
      var _self = this;

      this.$el.stop().animate({opacity: 0}, 150, function(){
        _self.render();
      });
    },

    _showCancel: function(ev) {
      ev.preventDefault();
      this.trigger('canceled');
      this.hide();
    },

    hide: function() {
      var self = this;
      this.$el.stop().animate({
        opacity: 0,
        bottom: "-35px"
      }, 500);
    }

  });<commit_msg>last steps with geocoder working<commit_after>
  /**
   *  Background geocoder to show the geocoding progress
   *
   *  - It needs a geocoder model.
   *
   *  new cdb.admin.BackgroundGeocoder({ model: geocoder })
   *
   */

  cdb.admin.BackgroundGeocoder = cdb.core.View.extend({

    events: {
      'click a.cancel': '_onCancel'
    },

    className: "background_importer",

    initialize: function() {
      _.bindAll(this, "show", "hide", "_onCancel");

      // Dropdown template
      this.template_base = cdb.templates.getTemplate(this.options.template_base);
    },

    render: function() {
      var content = this.template_base(this.model.toJSON());
      this.$el.html(content);

      if (content.length > 1) {
        this.$el.stop()
          .css({opacity: 1})
          .animate({
            bottom: "0px"
          }, 500);

        this.delegateEvents();
      }
      
      return this;
    },

    // when the importer is a geocoder bind its stats
    bindGeocoder: function() {
      var self = this;

      this.model.bind('geocodingStarted', this.changeState, this);
      this.model.bind('geocodingChange', this._setProgress, this);
      this.model.bind('geocodingReset geocodingComplete geocodingFailed', this.hide, this);
    },

    // Show progress but don't render again
    // the whole component
    _setProgress: function() {
      var attrs = this.model.toJSON();

      if (attrs.total_rows) {
        this.$('label.count').text(" " + attrs.processed_rows + "/" + attrs.total_rows);
      }
      
      if (attrs.state == "completed") {
        this.$('label.strong.light').html('FINISHING');
        this.$('label.count').remove(); 
        this.$('a.cancel').parent().remove();
      }

      if (!this.started) {
        this.changeState();
      }
    },

    changeState: function() {
      var self = this;

      this.started = true;

      this.$el.stop().animate({opacity: 0}, 150, function(){
        self.render();
      });
    },

    _onCancel: function(e) {
      e.preventDefault();
      this.model.cancelGeocoding(); // Cancel geocoding
      this.hide();
    },

    hide: function() {
      var self = this;
      this.started = false;
      this.$el.stop().animate({
        opacity: 0,
        bottom: "-35px"
      }, 500);
    }

  });
{'fraction_non_alphanumeric': 0.15272887323943662, 'fraction_numerical': 0.008362676056338027, 'mean_word_length': 2.07510148849797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3520175', 'n_tokens_mistral': 1455, 'n_tokens_neox': 1376, 'n_words': 280}