Class: Dina::Person
- Defined in:
- lib/dina/models/agent/person.rb
Class Method Summary collapse
- .endpoint_path ⇒ Object
-
.find_by_email(email:) ⇒ Object
Finds a Person object using an email address.
-
.search_by_name(name:) ⇒ Object
Searches for a Person by name using the search module.
- .table_name ⇒ Object
Methods inherited from BaseModel
custom_headers, find_by_group, #initialize, properties, site
Constructor Details
This class inherits a constructor from Dina::BaseModel
Class Method Details
.endpoint_path ⇒ Object
22 23 24 |
# File 'lib/dina/models/agent/person.rb', line 22 def self.endpoint_path "agent-api/" end |
.find_by_email(email:) ⇒ Object
Finds a Person object using an email address
34 35 36 |
# File 'lib/dina/models/agent/person.rb', line 34 def self.find_by_email(email:) where("email": email).all end |
.search_by_name(name:) ⇒ Object
Searches for a Person by name using the search module
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dina/models/agent/person.rb', line 42 def self.search_by_name(name:) payload = { query: { multi_match: { query: name, type: :cross_fields, fields: [ "data.attributes.familyNames^3", "data.attributes.givenNames", "data.attributes.displayName^5", "data.attributes.aliases", "data.attributes.displayName.autocomplete" ] } } } hits = Search.execute(index: "agent", payload: payload)[:hits] hits.map{|a| self.find(a[:_source][:data][:id]).first } end |
.table_name ⇒ Object
26 27 28 |
# File 'lib/dina/models/agent/person.rb', line 26 def self.table_name "person" end |