Class: Item::ImageLibraryPlPcLadder
- Inherits:
-
Object
- Object
- Item::ImageLibraryPlPcLadder
- Defined in:
- app/services/item/image_library_pl_pc_ladder.rb
Overview
Fetches images in PL×PC ladder order (leaf-to-root on both axes):
For each product line node from the root PL's path (most specific first):
- For each category node from the item's PC path (most specific first): exact PL + exact PC
- Then: images linked to that PL only (no category filter), excluding already seen
Path order: +self_and_ancestors_ids+ is root→leaf; we +reverse+ to walk leaf→root (see
Models::LtreeLineage). Uses explicit +product_line_id+ / +product_category_id+ joins so the
planner can use btree FKs and GiST indexes on +product_lines.ltree_path_ids+ /
+product_categories.ltree_path_ids+.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(base_scope:, item:, exclude_ids:, limit:) ⇒ ImageLibraryPlPcLadder
constructor
A new instance of ImageLibraryPlPcLadder.
Constructor Details
#initialize(base_scope:, item:, exclude_ids:, limit:) ⇒ ImageLibraryPlPcLadder
Returns a new instance of ImageLibraryPlPcLadder.
17 18 19 20 21 22 |
# File 'app/services/item/image_library_pl_pc_ladder.rb', line 17 def initialize(base_scope:, item:, exclude_ids:, limit:) @base_scope = base_scope @item = item @exclude_ids = exclude_ids @limit = limit end |
Class Method Details
.fetch(base_scope, item, exclude_ids: [], limit: 200) ⇒ Object
13 14 15 |
# File 'app/services/item/image_library_pl_pc_ladder.rb', line 13 def self.fetch(base_scope, item, exclude_ids: [], limit: 200) new(base_scope: base_scope, item: item, exclude_ids: exclude_ids, limit: limit).fetch end |
Instance Method Details
#fetch ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/services/item/image_library_pl_pc_ladder.rb', line 24 def fetch @seen = Set.new(@exclude_ids) @out = [] run_primary_ladder if @item.primary_product_line run_secondary_ladders @out.take(@limit) end |