Class: INat::Entity::ProjectObservationRule

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

Instance Attribute Summary collapse

Attributes inherited from Data::Entity

#id

Class 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

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

#operand_idtype: Integer

Returns the operand_id field.

Returns:

  • (type: Integer)

    the operand_id field



19
# File 'lib/inat/data/entity/projectobservationrule.rb', line 19

field :operand_id, type: Integer, index: true

#operand_typetype: Symbol

Returns the operand_type field.

Returns:

  • (type: Symbol)

    the operand_type field



18
# File 'lib/inat/data/entity/projectobservationrule.rb', line 18

field :operand_type, type: Symbol, index: true

#operatortype: Symbol

Returns the operator field.

Returns:

  • (type: Symbol)

    the operator field



17
# File 'lib/inat/data/entity/projectobservationrule.rb', line 17

field :operator, type: Symbol, index: true, required: true

#projecttype: Project

Returns the project field.

Returns:

  • (type: Project)

    the project field



15
# File 'lib/inat/data/entity/projectobservationrule.rb', line 15

field :project, type: Project, index: true

Class Method Details

.DDLObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/inat/data/entity/projectobservationrule.rb', line 23

def DDL
  super +
  "CREATE VIEW IF NOT EXISTS project_children AS\n" +
  "  SELECT project_id, operand_id as child_id\n" +
  "         FROM project_observation_rules\n" +
  "         WHERE operator = 'in_project?' AND operand_type = 'Project';\n" +
  "CREATE VIEW IF NOT EXISTS project_rule_taxa AS\n" +
  "  SELECT project_id, operand_id as taxon_id\n" +
  "         FROM project_observation_rules\n" +
  "         WHERE operator = 'in_taxon?' AND operand_type = 'Taxon';\n" +
  "CREATE VIEW IF NOT EXISTS project_rule_places AS\n" +
  "  SELECT project_id, operand_id as place_id\n" +
  "         FROM project_observation_rules\n" +
  "         WHERE operator = 'observed_in_place?' AND operand_type = 'Place';\n" +
  "CREATE VIEW IF NOT EXISTS project_rule_excluded_taxa AS\n" +
  "  SELECT project_id, operand_id as taxon_id\n" +
  "         FROM project_observation_rules\n" +
  "         WHERE operator = 'not_in_taxon?' AND operand_type = 'Taxon';\n" +
  "CREATE VIEW IF NOT EXISTS project_rule_excluded_places AS\n" +
  "  SELECT project_id, operand_id as place_id\n" +
  "         FROM project_observation_rules\n" +
  "         WHERE operator = 'not_observed_in_place?' AND operand_type = 'Place';\n"
end