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` 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