<commit_before>require 'active_model'
require 'aspect4r'
require 'cg_role_client/rest_endpoint'
require 'cg_service_client'

module CgRoleClient

  # A role type groups together a named set of activities that an actor or group
  # may be associated with by virtue of a granted role.
  class RoleType
    include CgServiceClient::Base

    uses_service("Role", "1", CgRoleClient::RestEndpoint)

    serializable_attr_accessor :id, :role_name, :target_type, :created_at, :updated_at

    validates_presence_of :role_name, :target_type
    validates_length_of :role_name, :target_type, :maximum=>255

    class << self
      def all
        with_endpoint do |endpoint|
          endpoint.find_all_role_types
        end
      end

      def find(id)
        with_endpoint do |endpoint|
          endpoint.find_role_type_by_id(id)
        end
      end

      def find_by_role_name_and_target_type(role_name, target_type)
        with_endpoint do |endpoint|
          endpoint.find_role_type_by_role_name_and_target_type(role_name, target_type)
        end
      end

      def method_missing(sym, *args, &block)
        logger.warn "CgRoleClient::RoleType.role_type('target_type') is deprecated, use CgRoleClient::RoleType.get(:role_type, 'target_type')"
        logger.warn "Called by #{caller.first}"
        self.find(sym.to_s, *args)
      end

      def get(sym, *args)
        find_by_role_name_and_target_type(sym.to_s, *args)
      end
    end

    def initialize(attributes = {})
      self.attributes = attributes
    end

    def activities
      with_endpoint do |endpoint|
        endpoint.find_role_type_activities_by_role_type_id(@id)
      end
    end
  end
end<commit_msg>PERFORMANCE IMPROVEMENT: CMTY-753, CMTY-754 Loading community activity stream and infinite page loading is improved.<commit_after>require 'active_model'
require 'aspect4r'
require 'cg_role_client/rest_endpoint'
require 'cg_service_client'

module CgRoleClient

  # A role type groups together a named set of activities that an actor or group
  # may be associated with by virtue of a granted role.
  class RoleType
    include CgServiceClient::Base

    uses_service("Role", "1", CgRoleClient::RestEndpoint)

    serializable_attr_accessor :id, :role_name, :target_type, :created_at, :updated_at

    validates_presence_of :role_name, :target_type
    validates_length_of :role_name, :target_type, :maximum=>255

    class << self
      def all
        with_endpoint do |endpoint|
          endpoint.find_all_role_types
        end
      end

      def find(id)
        with_endpoint do |endpoint|
          endpoint.find_role_type_by_id(id)
        end
      end

      def find_by_role_name_and_target_type(role_name, target_type)
        with_endpoint do |endpoint|
          endpoint.find_role_type_by_role_name_and_target_type(role_name, target_type)
        end
      end

      def method_missing(sym, *args, &block)
        logger.warn "CgRoleClient::RoleType.role_type('target_type') is deprecated, use CgRoleClient::RoleType.get(:role_type, 'target_type')"
        logger.warn "Called by #{caller.first}"
        self.find(sym.to_s, *args)
      end

      def get(sym, *args)
        find_by_role_name_and_target_type(sym.to_s, *args)
      end
    end

    def initialize(attributes = {})
      self.attributes = attributes
    end

    def activities
      with_endpoint do |endpoint|
        return @role_type_activities if defined? @role_type_activities
        @role_type_activities = endpoint.find_role_type_activities_by_role_type_id(@id)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07450980392156863, 'fraction_numerical': 0.004481792717086834, 'mean_word_length': 3.2613365155131264, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4988051', 'n_tokens_mistral': 1148, 'n_tokens_neox': 1119, 'n_words': 264}