Sha256: ebefe6ee7452bbc142d19aa3645c5bccc38a4267c099bc9a133de86c20d04066

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

module Eco
  module API
    module Organization
      class PeopleAnalytics <  Eco::API::Organization::People
        include Eco::Data::FuzzyMatch

        # @!group Helpers

        # @!endgroup

        # @!group Searchers

        # It gathers those that have the same `email`
        # @return [Hash] where `keys` are `email`s and `values` an `Array<Person>`
        def repeated_emails
          init_caches
          @by_email.select do |email, people|
            people.count > 1
          end
        end

        # @!endgroup

        # @!group Analysers

        # TODO: Sort results by `results.first.methods`
        def similarity(**options)
          each_with_object({}) do |person, results|
            results[person.id] = find_all_with_score(person, **options)
          end
        end


        def print_analysis(threshold)
          similarity.each do |id, results|
            msg = results.results.select do |result|
              result.threshold?(threshold)
            end.map do |result|
              result.print
            end.join("\n  ")

            puts "'#{self[id].identify}':\n  " + msg
          end
        end
        # @!endgroup

        protected

        def on_change
          remove_instance_variable(@fuzzy_match)
          super
        end

        private


      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eco-helpers-2.0.18 lib/eco/api/organization/people_analytics.rb
eco-helpers-2.0.17 lib/eco/api/organization/people_analytics.rb