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

angular.module('metadatamanagementApp').controller('ProjectCockpitController',
  function($q, $scope, $state, $location, $transitions, UserResource, Principal,
           PageTitleService, LanguageService, ToolbarHeaderService,
           DataAcquisitionProjectResource, SimpleMessageToastService,
           CurrentProjectService, projectDeferred, CommonDialogsService,
           SearchDao, QuestionUploadService, VariableUploadService, $translate,
           $mdDialog, ProjectReleaseService, $timeout,
           ProjectUpdateAccessService,
           DataAcquisitionProjectPostValidationService) {

    var pageTitleKey = 'data-acquisition-project-management.project' +
      '-cockpit.title';

    ToolbarHeaderService.updateToolbarHeader({
      stateName: $state.current.name
    });

    var setTypeCounts = function(projectId) {
      SearchDao.search('', 1, projectId, {}, undefined, 5, undefined)
        .then(function(data) {
          $scope.counts = {};
          ['variables', 'questions', 'data_sets', 'surveys', 'instruments',
            'studies'].forEach(function(type) {
            var bucket  = _.find(data.aggregations.countByType.buckets,
              {key: type});
            $scope.counts[type] = _.get(bucket, 'doc_count', 0);
          });
        });
    };
<commit_msg>#1844 Set pageSize to 0 to get counts in the cockpit<commit_after>/* global _ */
'use strict';

angular.module('metadatamanagementApp').controller('ProjectCockpitController',
  function($q, $scope, $state, $location, $transitions, UserResource, Principal,
           PageTitleService, LanguageService, ToolbarHeaderService,
           DataAcquisitionProjectResource, SimpleMessageToastService,
           CurrentProjectService, projectDeferred, CommonDialogsService,
           SearchDao, QuestionUploadService, VariableUploadService, $translate,
           $mdDialog, ProjectReleaseService, $timeout,
           ProjectUpdateAccessService,
           DataAcquisitionProjectPostValidationService) {

    var pageTitleKey = 'data-acquisition-project-management.project' +
      '-cockpit.title';

    ToolbarHeaderService.updateToolbarHeader({
      stateName: $state.current.name
    });

    var setTypeCounts = function(projectId) {
      SearchDao.search('', 1, projectId, {}, undefined, 0, undefined)
        .then(function(data) {
          $scope.counts = {};
          ['variables', 'questions', 'data_sets', 'surveys', 'instruments',
            'studies'].forEach(function(type) {
            var bucket  = _.find(data.aggregations.countByType.buckets,
              {key: type});
            $scope.counts[type] = _.get(bucket, 'doc_count', 0);
          });
        });
    };

{'fraction_non_alphanumeric': 0.11874314943368652, 'fraction_numerical': 0.00401899890390939, 'mean_word_length': 3.1929555895865236, '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': '1469127', 'n_tokens_mistral': 754, 'n_tokens_neox': 727, 'n_words': 134}