Class: INat::Entity::User

Inherits:
Data::Entity show all
Includes:
INat::Entity
Defined in:
lib/inat/data/entity/user.rb

Instance Attribute Summary collapse

Attributes inherited from Data::Entity

#id

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_counttype: Integer

Returns the activity_count field.

Returns:

  • (type: Integer)

    the activity_count field



36
# File 'lib/inat/data/entity/user.rb', line 36

field :activity_count, type: Integer

#created_attype: Time

Returns the created_at field.

Returns:

  • (type: Time)

    the created_at field



24
# File 'lib/inat/data/entity/user.rb', line 24

field :created_at, type: Time, index: true

#icontype: URI

Returns the icon field.

Returns:

  • (type: URI)

    the icon field



31
# File 'lib/inat/data/entity/user.rb', line 31

field :icon, type: URI

#icon_urltype: URI

Returns the icon_url field.

Returns:

  • (type: URI)

    the icon_url field



32
# File 'lib/inat/data/entity/user.rb', line 32

field :icon_url, type: URI

#identifications_counttype: Integer

Returns the identifications_count field.

Returns:

  • (type: Integer)

    the identifications_count field



34
# File 'lib/inat/data/entity/user.rb', line 34

field :identifications_count, type: Integer

#journal_posts_counttype: Integer

Returns the journal_posts_count field.

Returns:

  • (type: Integer)

    the journal_posts_count field



35
# File 'lib/inat/data/entity/user.rb', line 35

field :journal_posts_count, type: Integer

#logintype: String

Returns the login field.

Returns:

  • (type: String)

    the login field



21
# File 'lib/inat/data/entity/user.rb', line 21

field :login, type: String, index: true, required: true

#login_autocompletetype: String

Returns the login_autocomplete field.

Returns:

  • (type: String)

    the login_autocomplete field



26
# File 'lib/inat/data/entity/user.rb', line 26

field :login_autocomplete, type: String

#login_exacttype: String

Returns the login_exact field.

Returns:

  • (type: String)

    the login_exact field



27
# File 'lib/inat/data/entity/user.rb', line 27

field :login_exact, type: String

#nametype: String

Returns the name field.

Returns:

  • (type: String)

    the name field



28
# File 'lib/inat/data/entity/user.rb', line 28

field :name, type: String, index: true

#name_autocompletetype: String

Returns the name_autocomplete field.

Returns:

  • (type: String)

    the name_autocomplete field



29
# File 'lib/inat/data/entity/user.rb', line 29

field :name_autocomplete, type: String

#observations_counttype: Integer

Returns the observations_count field.

Returns:

  • (type: Integer)

    the observations_count field



33
# File 'lib/inat/data/entity/user.rb', line 33

field :observations_count, type: Integer

#orcidtype: URI

Returns the orcid field.

Returns:

  • (type: URI)

    the orcid field



30
# File 'lib/inat/data/entity/user.rb', line 30

field :orcid, type: URI

#site_idtype: Integer

Returns the site_id field.

Returns:

  • (type: Integer)

    the site_id field



25
# File 'lib/inat/data/entity/user.rb', line 25

field :site_id, type: Integer, index: true

#spamtype: Boolean

Returns the spam field.

Returns:

  • (type: Boolean)

    the spam field



22
# File 'lib/inat/data/entity/user.rb', line 22

field :spam, type: Boolean

#species_counttype: Integer

Returns the species_count field.

Returns:

  • (type: Integer)

    the species_count field



37
# File 'lib/inat/data/entity/user.rb', line 37

field :species_count, type: Integer

#suspendedtype: Boolean

Returns the suspended field.

Returns:

  • (type: Boolean)

    the suspended field



23
# File 'lib/inat/data/entity/user.rb', line 23

field :suspended, type: Boolean, index: true

#universal_search_ranktype: Integer

Returns the universal_search_rank field.

Returns:

  • (type: Integer)

    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. 
  @entities ||= {}
  results = @entities.values.select { |e| e. == .to_s }
  if results.empty?
    data = DB.execute "SELECT * FROM users WHERE login = ?", .to_s
    results = from_db_rows data
  end
  if results.empty?
    data = INat::API.query 'users/autocomplete', first_only: true, q: 
    results = data.select { |u| u['login'] == .to_s }.map { |d| parse(d) }
  end
  if results.empty?
    nil
  else
    results.first
  end
end

Instance Method Details

#sort_keyObject



43
44
45
# File 'lib/inat/data/entity/user.rb', line 43

def sort_key
  
end

#to_sObject



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> @#{  }"
end