Class: Retailer::UrlBackfill::Result

Inherits:
Data
  • Object
show all
Defined in:
app/services/retailer/url_backfill.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dry_runObject (readonly)

Returns the value of attribute dry_run

Returns:

  • (Object)

    the current value of dry_run



35
36
37
# File 'app/services/retailer/url_backfill.rb', line 35

def dry_run
  @dry_run
end

#outcomesObject (readonly)

Returns the value of attribute outcomes

Returns:

  • (Object)

    the current value of outcomes



35
36
37
# File 'app/services/retailer/url_backfill.rb', line 35

def outcomes
  @outcomes
end

Instance Method Details

#foundObject



36
# File 'app/services/retailer/url_backfill.rb', line 36

def found = outcomes.select(&:found?)

#missedObject



37
# File 'app/services/retailer/url_backfill.rb', line 37

def missed = outcomes.reject(&:found?)

#reportString

Returns a per-catalog found/missed summary plus every miss.

Returns:

  • (String)

    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