<commit_before>/**
 * The AnalysisToolPresenter class for the AnalysisToolView.
 *
 * @return AnalysisToolPresenter class.
 */
define([
  'map/presenters/PresenterClass',
  'underscore',
  'backbone',
  'mps',
  'topojson',
  'helpers/geojsonUtilsHelper',
  'map/services/CountryService',
  'map/services/RegionService'
], function(PresenterClass, _, Backbone, mps, topojson, geojsonUtilsHelper, countryService, regionService) {

  'use strict';

  var StatusModel = Backbone.Model.extend({
    defaults: {
      baselayer: null,
      resource: null, // analysis resource
      date: null,
      threshold: null,
      overlay: null, // google.maps.Polygon (user drawn polygon)
      multipolygon: null, // geojson (countries and regions multypolygon)
      disableUpdating: false
    }
  });

  var AnalysisToolPresenter = PresenterClass.extend({

    datasets: {
      'umd_tree_loss_gain': 'umd-loss-gain',
      'forma': 'forma-alerts',
      'imazon': 'imazon-alerts',
      'fires': 'nasa-active-fires',
      'modis': 'quicc-alerts'
    },

    init: function(view) {
      this.view = view;
      this.status = new StatusModel();
      this._super();
      mps.publish('Place/register', [this]);
    },

    /**
     * Application subscriptions.
     */
    _subscriptions: [{
      'Place/go': function(place) {
        this._setBaselayer(place.layerSpec.getBaselayers());
        this.status.set('date', [place.params.begin, place.params.end]);
        this.status.set('threshold', place.params.threshold);
        this._handlePlaceGo(place.params);
      }
    }, {
      'LayerNav/change': function(layerSpec) {
        this._setBaselayer(layerSpec.getBaselayers());
        this._updateAnalysis();
      }
    }, {
      'AnalysisTool/update-analysis': function() {
        this._updateAnalysis();
      }
    }, {
      'AnalysisResults/delete-analysis': function() {
        this.deleteAnalysis();
      }
    }, {
      'AnalysisTool/analyze-wdpaid': function(wdpaid) {
        this._analyzeWdpai(wdpaid.wdpaid);
      }
    }, {
      'Timeline/date-change': function(layerSlug, date) {
        this.status.set('date', date);
        this._updateAnalysis();
      }
    }, {
      'Timeline/start-playing': function() {
        this.status.set('disableUpdating', true);
      }
    }, {
      'Timeline/stop-playing': function() {
        this.status.set('disableUpdating', false);
        this._updateAnalysis();
      }
    }, {
      'Threshold/changed': function(threshold) {
        this.status.set('threshold', threshold);
        this._updateAnalysis();
      }
    }],

    /**
     * Handles a Place/go.
     *
     * @param  {Object} params Place params
     */
    _handlePlaceGo: function(params) {
      if (params.analyze) {
        this.view.onClickAnalysis();
      } else if (params.iso.country && params.iso.country !== 'ALL') {
        this._analyzeIso(params.iso);
      } else if (params.geojson) {
        this._analyzeGeojson(params.geojson);
      } else if (params.wdpaid) {
        this._analyzeWdpai(params.wdpaid);
      }
    },
<commit_msg>hotfix<commit_after>/**
 * The AnalysisToolPresenter class for the AnalysisToolView.
 *
 * @return AnalysisToolPresenter class.
 */
define([
  'map/presenters/PresenterClass',
  'underscore',
  'backbone',
  'mps',
  'topojson',
  'helpers/geojsonUtilsHelper',
  'map/services/CountryService',
  'map/services/RegionService'
], function(PresenterClass, _, Backbone, mps, topojson, geojsonUtilsHelper, countryService, regionService) {

  'use strict';

  var StatusModel = Backbone.Model.extend({
    defaults: {
      baselayer: null,
      resource: null, // analysis resource
      date: null,
      threshold: null,
      overlay: null, // google.maps.Polygon (user drawn polygon)
      multipolygon: null, // geojson (countries and regions multypolygon)
      disableUpdating: false
    }
  });

  var AnalysisToolPresenter = PresenterClass.extend({

    datasets: {
      'umd_tree_loss_gain': 'umd-loss-gain',
      'forma': 'forma-alerts',
      'imazon': 'imazon-alerts',
      'fires': 'nasa-active-fires',
      'modis': 'quicc-alerts'
    },

    init: function(view) {
      this.view = view;
      this.status = new StatusModel();
      this._super();
      mps.publish('Place/register', [this]);
    },

    /**
     * Application subscriptions.
     */
    _subscriptions: [{
      'Place/go': function(place) {
        this._setBaselayer(place.layerSpec.getBaselayers());
        this.status.set('date', [place.params.begin, place.params.end]);
        this.status.set('threshold', place.params.threshold);
        this._handlePlaceGo(place.params);
      }
    }, {
      'LayerNav/change': function(layerSpec) {
        this._setBaselayer(layerSpec.getBaselayers());
        this._updateAnalysis();
      }
    }, {
      'AnalysisTool/update-analysis': function() {
        this._updateAnalysis();
      }
    }, {
      'AnalysisResults/delete-analysis': function() {
        this.deleteAnalysis();
      }
    }, {
      'AnalysisTool/analyze-wdpaid': function(wdpaid) {
        this._analyzeWdpai(wdpaid.wdpaid);
      }
    }, {
      'Timeline/date-change': function(layerSlug, date) {
        this.status.set('date', date);
        this._updateAnalysis();
      }
    }, {
      'Timeline/start-playing': function() {
        this.status.set('disableUpdating', true);
      }
    }, {
      'Timeline/stop-playing': function() {
        this.status.set('disableUpdating', false);
        this._updateAnalysis();
      }
    }, {
      'Threshold/changed': function(threshold) {
        this.status.set('threshold', threshold);
        this._updateAnalysis();
      }
    }],

    /**
     * Handles a Place/go.
     *
     * @param  {Object} params Place params
     */
    _handlePlaceGo: function(params) {
      if (params.analyze && params.name === 'map') {
        this.view.onClickAnalysis();
      } else if (params.iso.country && params.iso.country !== 'ALL') {
        this._analyzeIso(params.iso);
      } else if (params.geojson) {
        this._analyzeGeojson(params.geojson);
      } else if (params.wdpaid) {
        this._analyzeWdpai(params.wdpaid);
      }
    },

{'fraction_non_alphanumeric': 0.14982240878269293, 'fraction_numerical': 0.0, 'mean_word_length': 2.531927023945268, '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': '4822513', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1922, 'n_words': 308}