Class: LargeTreeClassification

Inherits:
Object
  • Object
show all
Defined in:
backend/app/model/large_tree_classification.rb

Instance Method Summary collapse

Instance Method Details

#node(response, node_record) ⇒ Object



8
9
10
11
# File 'backend/app/model/large_tree_classification.rb', line 8

def node(response, node_record)
  response['identifier'] = node_record.identifier
  response
end

#root(response, root_record) ⇒ Object



3
4
5
6
# File 'backend/app/model/large_tree_classification.rb', line 3

def root(response, root_record)
  response['identifier'] = root_record.identifier
  response
end

#waypoint(response, record_ids) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'backend/app/model/large_tree_classification.rb', line 13

def waypoint(response, record_ids)
  # Add identifier to nodes
  ClassificationTerm
      .filter(:classification_term__id => record_ids)
      .select(Sequel.as(:classification_term__id, :id),
              Sequel.as(:classification_term__identifier, :identifier))
      .each do |row|

    id = row[:id]
    result_for_record = response.fetch(record_ids.index(id))
    result_for_record['identifier'] = row[:identifier]
  end

  response
end