<commit_before>'use strict';

angular.module('sumaAnalysis')
  .factory('scopeUtils', function ($q, actsLocs, validation) {
    return {
      stringifyDays: function (days) {
        var string;

        if (!days || days.length === 0) {
          return null;
        }

        string = days.join(',');

        return string;
      },
      stringifyActs: function (acts, filter, actGrpMode) {
        var actAry = [];

        if (actGrpMode) {
          _.each(acts, function (act) {
            if (act.type === 'activityGroup' && act.filter === filter) {
              actAry.push(act.id);
            }
          });
        } else {
          _.each(acts, function (act) {
            if (act.type === 'activity' && act.filter === filter && act.enabled === true) {
              actAry.push(act.id);
            }
          });
        }

        return actAry.join();
      },
      mapActs: function (acts, excludeActGrpsAry, requireActGrpsAry, excludeActsAry, requireActsAry) {
        return _.map(acts, function (act) {
          if (act.type === 'activityGroup') {
            if (_.contains(excludeActGrpsAry, String(act.id))) {
              act.filter = 'exclude';
            } else if (_.contains(requireActGrpsAry, String(act.id))) {
              act.filter = 'require';
            } else {
              act.filter = 'allow';
            }
          } else {
            if (_.contains(excludeActsAry, String(act.id))) {
              act.filter = 'exclude';
            } else if (_.contains(requireActsAry, String(act.id))) {
              act.filter = 'require';
            } else {
              act.filter = 'allow';
            }
          }

          return act;
        });
      },
      getMetadata: function (init) {
        return actsLocs.get(init);
      },
      set: function (urlParams, sumaConfig, inits) {
        var activities,
            dfd = $q.defer(),<commit_msg>add getCurrentScope method<commit_after>'use strict';

angular.module('sumaAnalysis')
  .factory('scopeUtils', function ($q, actsLocs, validation) {
    return {
      stringifyDays: function (days) {
        var string;

        if (!days || days.length === 0) {
          return null;
        }

        string = days.join(',');

        return string;
      },
      stringifyActs: function (acts, filter, actGrpMode) {
        var actAry = [];

        if (actGrpMode) {
          _.each(acts, function (act) {
            if (act.type === 'activityGroup' && act.filter === filter) {
              actAry.push(act.id);
            }
          });
        } else {
          _.each(acts, function (act) {
            if (act.type === 'activity' && act.filter === filter && act.enabled === true) {
              actAry.push(act.id);
            }
          });
        }

        return actAry.join();
      },
      mapActs: function (acts, excludeActGrpsAry, requireActGrpsAry, excludeActsAry, requireActsAry) {
        return _.map(acts, function (act) {
          if (act.type === 'activityGroup') {
            if (_.contains(excludeActGrpsAry, String(act.id))) {
              act.filter = 'exclude';
            } else if (_.contains(requireActGrpsAry, String(act.id))) {
              act.filter = 'require';
            } else {
              act.filter = 'allow';
            }
          } else {
            if (_.contains(excludeActsAry, String(act.id))) {
              act.filter = 'exclude';
            } else if (_.contains(requireActsAry, String(act.id))) {
              act.filter = 'require';
            } else {
              act.filter = 'allow';
            }
          }

          return act;
        });
      },
      getMetadata: function (init) {
        return actsLocs.get(init);
      },
      getCurrentScope: function (params, acts) {
        return _.compactObject({
          id:             String(params.init.id),
          sdate:          params.sdate || params.sdate === '' ? params.sdate : null,
          edate:          params.edate || params.edate === '' ? params.edate : null,
          stime:          params.stime || params.stime === '' ? params.stime : null,
          etime:          params.etime || params.etime === '' ? params.etime : null,
          classifyCounts: params.classifyCounts ? params.classifyCounts.id : null,
          wholeSession:   params.wholeSession ? params.wholeSession.id : null,
          zeroCounts:     params.zeroCounts ? params.zeroCounts.id : null,
          requireActs:    this.stringifyActs(acts, 'require'),
          excludeActs:    this.stringifyActs(acts, 'exclude'),
          requireActGrps: this.stringifyActs(acts, 'require', true),
          excludeActGrps: this.stringifyActs(acts, 'exclude', true),
          location:       params.location ? params.location.id : null,
          days:           this.stringifyDays(params.days)
        });
      },
      set: function (urlParams, sumaConfig, inits) {
        var activities,
            dfd = $q.defer(),
{'fraction_non_alphanumeric': 0.13802816901408452, 'fraction_numerical': 0.00040241448692152917, 'mean_word_length': 1.6597110754414126, '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': '4141888', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1420, 'n_words': 291}