<commit_before>/* global _ */
'use strict';

angular.module('metadatamanagementApp').controller('ShoppingCartController',
  function(PageTitleService, $state, ToolbarHeaderService,
           ShoppingCartService, $scope, StudyResource, DataSetSearchService,
           VariableSearchService, DataAcquisitionProjectReleasesResource, $q,
           OrderResource, LanguageService, SimpleMessageToastService, order,
           DataAcquisitionProjectResource, $window, $interval, $location) {

    PageTitleService.setPageTitle('shopping-cart.title');
    ToolbarHeaderService.updateToolbarHeader({
      'stateName': $state.current.name
    });
    var ctrl = this;
    var existingOrderId;
    var intervalReference;
    ctrl.dataAcquisitionProjects = {};
    ctrl.studies = {};
    ctrl.releases = {};
    ctrl.counts = {};
    ctrl.initComplete = false;
    ctrl.redirectCountDownSeconds = 5;

    $scope.$on('$destroy', function() {
      if (intervalReference) {
        $interval.cancel(intervalReference);
      }
    });

    var redirectAfterCountDown = function(interval, location, languageKey,
                                          orderId) {
      interval.then(function() {
        $interval.cancel(interval);
        $location.path('/' + languageKey + '/shopping-cart/' + orderId)
          .replace();
        if (location) {
          $window.open(location, '_self');
        }
      });
    };

    var initViewWithOrderResource = function(order) {
      order.$promise.then(function(order) {
        ShoppingCartService
          .initShoppingCartProducts(_.get(order, 'products', []), order.id,
            order.version);
      }, function(error) {
        if (error.status === 404) {
          ShoppingCartService.clearLocalOrderId();
        }
      }).finally(ctrl.init);
    };
<commit_msg>#2010 prevent shopping cart restore<commit_after>/* global _ */
'use strict';

angular.module('metadatamanagementApp').controller('ShoppingCartController',
  function(PageTitleService, $state, ToolbarHeaderService,
           ShoppingCartService, $scope, StudyResource, DataSetSearchService,
           VariableSearchService, DataAcquisitionProjectReleasesResource, $q,
           OrderResource, LanguageService, SimpleMessageToastService, order,
           DataAcquisitionProjectResource, $window, $interval, $location,
           $transitions) {

    PageTitleService.setPageTitle('shopping-cart.title');
    ToolbarHeaderService.updateToolbarHeader({
      'stateName': $state.current.name
    });
    var ctrl = this;
    var existingOrderId;
    var intervalReference;
    ctrl.dataAcquisitionProjects = {};
    ctrl.studies = {};
    ctrl.releases = {};
    ctrl.counts = {};
    ctrl.initComplete = false;
    ctrl.redirectCountDownSeconds = 5;

    $scope.$on('$destroy', function() {
      if (intervalReference) {
        $interval.cancel(intervalReference);
      }
    });

    var redirectAfterCountDown = function(interval, location, languageKey,
                                          orderId) {
      interval.then(function() {
        $interval.cancel(interval);
        $transitions.onBefore({}, function(transition) {
          if (transition.$to().name === 'restoreShoppingCart') {
            return false;
          }
        });
        $location.path('/' + languageKey + '/shopping-cart/' + orderId)
          .replace();
        if (location) {
          $window.open(location, '_self');
        }
      });
    };

    var initViewWithOrderResource = function(order) {
      order.$promise.then(function(order) {
        ShoppingCartService
          .initShoppingCartProducts(_.get(order, 'products', []), order.id,
            order.version);
      }, function(error) {
        if (error.status === 404) {
          ShoppingCartService.clearLocalOrderId();
        }
      }).finally(ctrl.init);
    };

{'fraction_non_alphanumeric': 0.1252273317744869, 'fraction_numerical': 0.003117692907248636, 'mean_word_length': 2.6736641221374047, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4825798', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1026, 'n_words': 170}