<commit_before>(function () {
  "use strict";

  angular
    .module('mnPromiseHelper', [
      'mnAlertsService',
      'mnHelper'
    ])
    .factory('mnPromiseHelper', mnPromiseHelperFactory);

  function mnPromiseHelperFactory(mnAlertsService, mnHelper, $timeout, $rootScope) {

    mnPromiseHelper.handleModalAction = handleModalAction;

    return mnPromiseHelper;

    function handleModalAction($scope, promise, $uibModalInstance, vm) {
      return mnPromiseHelper(vm || $scope, promise, $uibModalInstance)
        .showErrorsSensitiveSpinner()
        .closeFinally()
        .reloadState();
    }

    function mnPromiseHelper(scope, promise, modalInstance) {
      var spinnerNameOrFunction = 'viewLoading';
      var errorsNameOrCallback = 'errors';
      var pendingGlobalSpinnerQueries = {};
      var spinnerTimeout;
      var promiseHelper = {
        applyToScope: applyToScope,
        getPromise: getPromise,
        onSuccess: onSuccess,
        reloadState: reloadState,
        closeFinally: closeFinally,
        closeOnSuccess: closeOnSuccess,
        showErrorsSensitiveSpinner: showErrorsSensitiveSpinner,
        catchErrorsFromSuccess: catchErrorsFromSuccess,
        showSpinner: showSpinner,
        showGlobalSpinner: showGlobalSpinner,
        catchErrors: catchErrors,
        catchGlobalErrors: catchGlobalErrors,
        showGlobalSuccess: showGlobalSuccess,
        broadcast: broadcast
      }

      return promiseHelper;

      function getPromise() {
        return promise;
      }
      function onSuccess(cb) {
        promise.then(cb);
        return this;
      }
      function reloadState() {
        promise.then(function () {
          spinnerCtrl(true);
          mnHelper.reloadState();
        });
        return this;
      }
      function closeFinally() {
        promise['finally'](closeModal);
        return this;
      }
      function closeOnSuccess() {
        promise.then(closeModal);
        return this;
      }
      function showErrorsSensitiveSpinner(name, timer, scope) {
        name && setSpinnerName(name);
        maybeHandleSpinnerWithTimer(timer, scope);
        promise.then(clearSpinnerTimeout, hideSpinner);
        return this;
      }
      function catchErrorsFromSuccess(nameOrCallback) {
        nameOrCallback && setErrorsNameOrCallback(nameOrCallback);
        promise.then(function (resp) {
          errorsCtrl(extractErrors(resp));
        });
        return this;
      }
      function showSpinner(name, timer, scope) {
        name && setSpinnerName(name);
        maybeHandleSpinnerWithTimer(timer, scope);
        promise.then(hideSpinner, hideSpinner);
        return this;
      }

      function showGlobalSpinner(timer) {
        var id = doShowGlobalSpinner();
        promise.then(hideGlobalSpinner(id), hideGlobalSpinner(id));
        return this;
      }
      function catchErrors(nameOrCallback) {
        nameOrCallback && setErrorsNameOrCallback(nameOrCallback);
        promise.then(removeErrors, function (resp) {
          errorsCtrl(extractErrors(resp));
        });
        return this;
      }
      function catchGlobalErrors(errorMessage, timeout) {
        promise.then(null, function (resp) {
          mnAlertsService.showAlertInPopup(errorMessage || extractErrors(resp.data), 'error', timeout);<commit_msg>MB-19848: ignore cancelled queries in catchErrors and catchGlobalErrors<commit_after>(function () {
  "use strict";

  angular
    .module('mnPromiseHelper', [
      'mnAlertsService',
      'mnHelper'
    ])
    .factory('mnPromiseHelper', mnPromiseHelperFactory);

  function mnPromiseHelperFactory(mnAlertsService, mnHelper, $timeout, $rootScope) {

    mnPromiseHelper.handleModalAction = handleModalAction;

    return mnPromiseHelper;

    function handleModalAction($scope, promise, $uibModalInstance, vm) {
      return mnPromiseHelper(vm || $scope, promise, $uibModalInstance)
        .showErrorsSensitiveSpinner()
        .closeFinally()
        .reloadState();
    }

    function mnPromiseHelper(scope, promise, modalInstance) {
      var spinnerNameOrFunction = 'viewLoading';
      var errorsNameOrCallback = 'errors';
      var pendingGlobalSpinnerQueries = {};
      var spinnerTimeout;
      var promiseHelper = {
        applyToScope: applyToScope,
        getPromise: getPromise,
        onSuccess: onSuccess,
        reloadState: reloadState,
        closeFinally: closeFinally,
        closeOnSuccess: closeOnSuccess,
        showErrorsSensitiveSpinner: showErrorsSensitiveSpinner,
        catchErrorsFromSuccess: catchErrorsFromSuccess,
        showSpinner: showSpinner,
        showGlobalSpinner: showGlobalSpinner,
        catchErrors: catchErrors,
        catchGlobalErrors: catchGlobalErrors,
        showGlobalSuccess: showGlobalSuccess,
        broadcast: broadcast
      }

      return promiseHelper;

      function getPromise() {
        return promise;
      }
      function onSuccess(cb) {
        promise.then(cb);
        return this;
      }
      function reloadState() {
        promise.then(function () {
          spinnerCtrl(true);
          mnHelper.reloadState();
        });
        return this;
      }
      function closeFinally() {
        promise['finally'](closeModal);
        return this;
      }
      function closeOnSuccess() {
        promise.then(closeModal);
        return this;
      }
      function showErrorsSensitiveSpinner(name, timer, scope) {
        name && setSpinnerName(name);
        maybeHandleSpinnerWithTimer(timer, scope);
        promise.then(clearSpinnerTimeout, hideSpinner);
        return this;
      }
      function catchErrorsFromSuccess(nameOrCallback) {
        nameOrCallback && setErrorsNameOrCallback(nameOrCallback);
        promise.then(function (resp) {
          errorsCtrl(extractErrors(resp));
        });
        return this;
      }
      function showSpinner(name, timer, scope) {
        name && setSpinnerName(name);
        maybeHandleSpinnerWithTimer(timer, scope);
        promise.then(hideSpinner, hideSpinner);
        return this;
      }

      function showGlobalSpinner(timer) {
        var id = doShowGlobalSpinner();
        promise.then(hideGlobalSpinner(id), hideGlobalSpinner(id));
        return this;
      }
      function catchErrors(nameOrCallback) {
        nameOrCallback && setErrorsNameOrCallback(nameOrCallback);
        promise.then(removeErrors, function (resp) {
          if (resp.status !== -1) {
            errorsCtrl(extractErrors(resp));
          }
        });
        return this;
      }
      function catchGlobalErrors(errorMessage, timeout) {
        promise.then(null, function (resp) {
          if (resp.status !== -1) {
            mnAlertsService.showAlertInPopup(errorMessage || extractErrors(resp.data), 'error', timeout);
          }
{'fraction_non_alphanumeric': 0.09197766676461945, 'fraction_numerical': 0.001028504260946224, 'mean_word_length': 2.6695417789757414, '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': '5211590', 'n_tokens_mistral': 1824, 'n_tokens_neox': 1806, 'n_words': 342}