Class: INat::Entity::User
- Inherits:
-
Data::Entity
- Object
- Data::Model
- Data::Entity
- INat::Entity::User
- Includes:
- INat::Entity
- Defined in:
- lib/inat/data/entity/user.rb
Instance Attribute Summary collapse
-
#activity_count ⇒ type: Integer
The
activity_count
field. -
#created_at ⇒ type: Time
The
created_at
field. -
#icon ⇒ type: URI
The
icon
field. -
#icon_url ⇒ type: URI
The
icon_url
field. -
#identifications_count ⇒ type: Integer
The
identifications_count
field. -
#journal_posts_count ⇒ type: Integer
The
journal_posts_count
field. -
#login ⇒ type: String
The
login
field. -
#login_autocomplete ⇒ type: String
The
login_autocomplete
field. -
#login_exact ⇒ type: String
The
login_exact
field. -
#name ⇒ type: String
The
name
field. -
#name_autocomplete ⇒ type: String
The
name_autocomplete
field. -
#observations_count ⇒ type: Integer
The
observations_count
field. -
#orcid ⇒ type: URI
The
orcid
field. -
#site_id ⇒ type: Integer
The
site_id
field. -
#spam ⇒ type: Boolean
The
spam
field. -
#species_count ⇒ type: Integer
The
species_count
field. -
#suspended ⇒ type: Boolean
The
suspended
field. -
#universal_search_rank ⇒ type: Integer
The
universal_search_rank
field.
Attributes inherited from Data::Entity
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Data::Entity
by_id, #complete?, ddl, fetch, from_db_rows, #get, #init, #initialize, load, load_file, parse, read, #save, #to_db, #update
Methods included from App::Logger::DSL
#debug, debug, echo, #echo, error, #error, #info, info, log, #log, #warning, warning
Methods inherited from Data::Model
DDL, api_limit, api_part, api_path, backs, block, field, fields, has_path?, has_table?, #ignore, #initialize, links, #post_update, #process?, #saved?, table, #to_h, #update
Constructor Details
This class inherits a constructor from INat::Data::Entity
Instance Attribute Details
#activity_count ⇒ type: Integer
Returns the activity_count
field.
36 |
# File 'lib/inat/data/entity/user.rb', line 36 field :activity_count, type: Integer |
#created_at ⇒ type: Time
Returns the created_at
field.
24 |
# File 'lib/inat/data/entity/user.rb', line 24 field :created_at, type: Time, index: true |
#icon ⇒ type: URI
Returns the icon
field.
31 |
# File 'lib/inat/data/entity/user.rb', line 31 field :icon, type: URI |
#icon_url ⇒ type: URI
Returns the icon_url
field.
32 |
# File 'lib/inat/data/entity/user.rb', line 32 field :icon_url, type: URI |
#identifications_count ⇒ type: Integer
Returns the identifications_count
field.
34 |
# File 'lib/inat/data/entity/user.rb', line 34 field :identifications_count, type: Integer |
#journal_posts_count ⇒ type: Integer
Returns the journal_posts_count
field.
35 |
# File 'lib/inat/data/entity/user.rb', line 35 field :journal_posts_count, type: Integer |
#login ⇒ type: String
Returns the login
field.
21 |
# File 'lib/inat/data/entity/user.rb', line 21 field :login, type: String, index: true, required: true |
#login_autocomplete ⇒ type: String
Returns the login_autocomplete
field.
26 |
# File 'lib/inat/data/entity/user.rb', line 26 field :login_autocomplete, type: String |
#login_exact ⇒ type: String
Returns the login_exact
field.
27 |
# File 'lib/inat/data/entity/user.rb', line 27 field :login_exact, type: String |
#name ⇒ type: String
Returns the name
field.
28 |
# File 'lib/inat/data/entity/user.rb', line 28 field :name, type: String, index: true |
#name_autocomplete ⇒ type: String
Returns the name_autocomplete
field.
29 |
# File 'lib/inat/data/entity/user.rb', line 29 field :name_autocomplete, type: String |
#observations_count ⇒ type: Integer
Returns the observations_count
field.
33 |
# File 'lib/inat/data/entity/user.rb', line 33 field :observations_count, type: Integer |
#orcid ⇒ type: URI
Returns the orcid
field.
30 |
# File 'lib/inat/data/entity/user.rb', line 30 field :orcid, type: URI |
#site_id ⇒ type: Integer
Returns the site_id
field.
25 |
# File 'lib/inat/data/entity/user.rb', line 25 field :site_id, type: Integer, index: true |
#spam ⇒ type: Boolean
Returns the spam
field.
22 |
# File 'lib/inat/data/entity/user.rb', line 22 field :spam, type: Boolean |
#species_count ⇒ type: Integer
Returns the species_count
field.
37 |
# File 'lib/inat/data/entity/user.rb', line 37 field :species_count, type: Integer |
#suspended ⇒ type: Boolean
Returns the suspended
field.
23 |
# File 'lib/inat/data/entity/user.rb', line 23 field :suspended, type: Boolean, index: true |
#universal_search_rank ⇒ type: Integer
Returns the universal_search_rank
field.
38 |
# File 'lib/inat/data/entity/user.rb', line 38 field :universal_search_rank, type: Integer |
Class Method Details
.by_login(login) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/inat/data/entity/user.rb', line 47 def self.by_login login @entities ||= {} results = @entities.values.select { |e| e.login == login.to_s } if results.empty? data = DB.execute "SELECT * FROM users WHERE login = ?", login.to_s results = from_db_rows data end if results.empty? data = INat::API.query 'users/autocomplete', first_only: true, q: login results = data.select { |u| u['login'] == login.to_s }.map { |d| parse(d) } end if results.empty? nil else results.first end end |
Instance Method Details
#sort_key ⇒ Object
43 44 45 |
# File 'lib/inat/data/entity/user.rb', line 43 def sort_key login end |
#to_s ⇒ Object
65 66 67 68 69 |
# File 'lib/inat/data/entity/user.rb', line 65 def to_s title = '' title = " title=\"#{ name }\"" if name "<a#{ title } href=\"https://www.inaturalist.org/people/#{ id }\"><i class=\"glyphicon glyphicon-user\"></i></a> @#{ login }" end |