<commit_before>(function() {
  'use strict';
  angular.module('civic.services')
    .factory('UsersResource', UsersResource)
    .factory('Users', UsersService);

  // @ngInject
  function UsersResource($resource, UserOrgsInterceptor) {
    //var cache = $cacheFactory.get('$http');

    //var cacheInterceptor = function(response) {
    //  console.log(['EvidenceResource: removing', response.config.url, 'from $http cache.'].join(' '));
    //  cache.remove(response.config.url);
    //  return response.$promise;
    //};


    return $resource('/api/users/:userId',
      {
        userId: '@userId'
      },
      {
        get: {
          method: 'GET',
          isArray: false,
          cache: false,
          interceptor: {
            response: UserOrgsInterceptor
          }
        },
        query: {
          method: 'GET',
          isArray: false,
          cache: false
        },
        update: {
          method: 'PATCH',
          params: {
            userId: '@id'
          },
          cache: false
        },
        queryEvents: {
          url: '/api/users/:userId/events',
          method: 'GET',
          isArray: false,
          cache: false
        }
      }
    );
  }

  // @ngInject
  function UsersService($q, UsersResource, UserOrgsInterceptor) {
    var item = { };
    var collection = [];
    var events = [];

    return {
      data: {
        item: item,
        collection: collection,
        events: events
      },
      get: get,
      query: query,
      queryEvents: queryEvents,
      update: update
    };

    function get(userId) {
      return UsersResource.get({userId: userId}).$promise
        .then(function(response) {
          angular.copy(response, item);
          return $q.when(response); // kludge to handle UserOrgsInterceptor returning $promise-less response
        });
    }
    function query(reqObj) {
      return UsersResource.query(reqObj).$promise
        .then(function(response) {
          response.result = response.result.map(function(u) {
            var mock = {};
            mock.data = u;
            return UserOrgsInterceptor(mock);
          });
          angular.copy(response, collection);
          return response.$promise;
        });
    }
    function queryEvents(userId) {
      return UsersResource.queryEvents({userId: userId}).$promise
        .then(function(response) {
          angular.copy(response, events);
          return response.$promise;<commit_msg>added logic to Users resource to apply orgs interceptor logic manually<commit_after>(function() {
  'use strict';
  angular.module('civic.services')
    .factory('UsersResource', UsersResource)
    .factory('Users', UsersService);

  // @ngInject
  function UsersResource($resource, UserOrgsInterceptor) {
    //var cache = $cacheFactory.get('$http');

    //var cacheInterceptor = function(response) {
    //  console.log(['EvidenceResource: removing', response.config.url, 'from $http cache.'].join(' '));
    //  cache.remove(response.config.url);
    //  return response.$promise;
    //};


    return $resource('/api/users/:userId',
      {
        userId: '@userId'
      },
      {
        get: {
          method: 'GET',
          isArray: false,
          cache: false,
        },
        query: {
          method: 'GET',
          isArray: false,
          cache: false
        },
        update: {
          method: 'PATCH',
          params: {
            userId: '@id'
          },
          cache: false
        },
        queryEvents: {
          url: '/api/users/:userId/events',
          method: 'GET',
          isArray: false,
          cache: false
        }
      }
    );
  }

  // @ngInject
  function UsersService($q, UsersResource, UserOrgsInterceptor) {
    var item = { };
    var collection = [];
    var events = [];

    return {
      data: {
        item: item,
        collection: collection,
        events: events
      },
      get: get,
      query: query,
      queryEvents: queryEvents,
      update: update
    };

    function get(userId) {
      return UsersResource.get({userId: userId}).$promise
        .then(function(response) {
          // use orgs interceptor to apply most recent org logic
          var mock = {};
          mock.data = response;
          response = UserOrgsInterceptor(mock);
          angular.copy(response, item);
          return response.$promise;
        });
    }
    function query(reqObj) {
      return UsersResource.query(reqObj).$promise
        .then(function(response) {
          // use orgs interceptor to apply most recent org logic
          response.result = response.result.map(function(u) {
            var mock = {};
            mock.data = u;
            return UserOrgsInterceptor(mock);
          });
          angular.copy(response, collection);
          return response.$promise;
        });
    }
    function queryEvents(userId) {
      return UsersResource.queryEvents({userId: userId}).$promise
        .then(function(response) {
          angular.copy(response, events);
          return response.$promise;
{'fraction_non_alphanumeric': 0.1281496062992126, 'fraction_numerical': 0.0, 'mean_word_length': 1.8385474860335196, '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': '6331277', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1406, 'n_words': 295}