<commit_before>require 'json'
require 'chef_zero/rest_base'

module ChefZero
  module Endpoints
    # /users/NAME/association_requests/count
    class UserAssociationRequestsCountEndpoint < RestBase
      def get(request)
        get_data(request, request.rest_path[0..-2])

        username = request.rest_path[1]
        result = list_data(request, [ 'organizations' ]).select do |org|
          exists_data?(request, [ 'organizations', org, 'association_requests', username ])
        end
        json_response(200, { "value" => result.size })
      end
    end
  end
end<commit_msg>Fix 404 in assoc. request count to be correct<commit_after>require 'json'
require 'chef_zero/rest_base'

module ChefZero
  module Endpoints
    # /users/NAME/association_requests/count
    class UserAssociationRequestsCountEndpoint < RestBase
      def get(request)
        get_data(request, request.rest_path[0..-3])

        username = request.rest_path[1]
        result = list_data(request, [ 'organizations' ]).select do |org|
          exists_data?(request, [ 'organizations', org, 'association_requests', username ])
        end
        json_response(200, { "value" => result.size })
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.10548172757475083, 'fraction_numerical': 0.012458471760797342, 'mean_word_length': 3.2132867132867133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5396430', 'n_tokens_mistral': 372, 'n_tokens_neox': 362, 'n_words': 81}