Class: AmazonBrowseNode

Inherits:
ApplicationRecord show all
Defined in:
app/models/amazon_browse_node.rb

Overview

== Schema Information

Table name: amazon_browse_nodes
Database name: primary

id :bigint not null, primary key
item_type_keyword :string
node_path :text not null
created_at :datetime not null
updated_at :datetime not null
amazon_marketplace_id :integer not null
node_id :string not null

Indexes

index_amazon_browse_nodes_on_item_type_keyword (item_type_keyword) USING gin
index_amazon_browse_nodes_on_node_id (node_id)
index_amazon_browse_nodes_on_node_path (node_path) USING gin
unique_amazon_browse_nodes (amazon_marketplace_id, node_id, COALESCE(item_type_keyword, ''::character varying))

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Has and belongs to many collapse

Belongs to collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#node_idString

Returns Amazon browse node id.

Returns:

  • (String)

    Amazon browse node id.



37
# File 'app/models/amazon_browse_node.rb', line 37

validates :node_id, presence: true

#node_pathString

Returns Human-readable browse node path.

Returns:

  • (String)

    Human-readable browse node path.

Validations:



37
# File 'app/models/amazon_browse_node.rb', line 37

validates :node_id, presence: true

Class Method Details

.search_nodeActiveRecord::Relation<AmazonBrowseNode>

A relation of AmazonBrowseNodes that are search node. Active Record Scope

Returns:

See Also:



40
41
42
43
44
45
# File 'app/models/amazon_browse_node.rb', line 40

scope :search_node, ->(q) {
  q_wild = "'%#{q}%'".sql_safe
  where(AmazonBrowseNode[:node_id].eq(q)
               .or(AmazonBrowseNode[:node_path].matches(q_wild))
               .or(AmazonBrowseNode[:item_type_keyword].matches(q_wild)))
}

Instance Method Details

#amazon_marketplaceAmazonMarketplace

Returns:



31
# File 'app/models/amazon_browse_node.rb', line 31

belongs_to :amazon_marketplace

#catalog_itemsActiveRecord::Relation<CatalogItem>

Returns:



25
# File 'app/models/amazon_browse_node.rb', line 25

has_and_belongs_to_many :catalog_items

#to_sString

Returns:

  • (String)


48
49
50
# File 'app/models/amazon_browse_node.rb', line 48

def to_s
  %(#{node_id} - #{node_path}#{"#{+' ('}#{item_type_keyword})" if item_type_keyword} [#{amazon_marketplace.country.iso}])
end

#variant_groupsActiveRecord::Relation<VariantGroup>

Returns:



27
28
# File 'app/models/amazon_browse_node.rb', line 27

has_and_belongs_to_many :variant_groups,
join_table: 'amazon_browse_nodes_variant_groups'