Class: Retailer::UrlBackfill::Result
- Inherits:
-
Data
- Object
- Data
- Retailer::UrlBackfill::Result
- Defined in:
- app/services/retailer/url_backfill.rb
Instance Attribute Summary collapse
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#outcomes ⇒ Object
readonly
Returns the value of attribute outcomes.
Instance Method Summary collapse
- #found ⇒ Object
- #missed ⇒ Object
-
#report ⇒ String
A per-catalog found/missed summary plus every miss.
Instance Attribute Details
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run
35 36 37 |
# File 'app/services/retailer/url_backfill.rb', line 35 def dry_run @dry_run end |
#outcomes ⇒ Object (readonly)
Returns the value of attribute outcomes
35 36 37 |
# File 'app/services/retailer/url_backfill.rb', line 35 def outcomes @outcomes end |
Instance Method Details
#found ⇒ Object
36 |
# File 'app/services/retailer/url_backfill.rb', line 36 def found = outcomes.select(&:found?) |
#missed ⇒ Object
37 |
# File 'app/services/retailer/url_backfill.rb', line 37 def missed = outcomes.reject(&:found?) |
#report ⇒ String
Returns a per-catalog found/missed summary plus every miss.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/services/retailer/url_backfill.rb', line 40 def report prefix = dry_run ? '[DRY RUN] ' : nil lines = ["#{prefix}#{found.size}/#{outcomes.size} URLs recovered"] outcomes.group_by(&:catalog_name).sort_by { |name, _| name.to_s }.each do |name, group| hits = group.count(&:found?) lines << format(' %-38s %3d/%-3d', name, hits, group.size) end unless missed.empty? lines << "\nNot found (retailer likely does not carry these — treat as listing issues):" missed.sort_by { |o| [o.catalog_name.to_s, o.sku.to_s] } .each { |o| lines << " #{o.catalog_name} #{o.sku} (catalog_item #{o.catalog_item_id})" } end lines.join("\n") end |