more stuff
This commit is contained in:
+33
-7
@@ -201,6 +201,19 @@ type itemGroup struct {
|
||||
// become authoritative for what the projection carries; HTTP stays for
|
||||
// dimensions (parent width/height for child pricing), seller/orgPrice and the
|
||||
// dynamic ExtraJson product data. Skipped cleanly when idx is nil.
|
||||
//
|
||||
// Cache-only fast path: a parent with NO children AND a cache hit that
|
||||
// satisfies HasRequiredFields skips PRODUCT_BASE_URL entirely — BuildAddItem-
|
||||
// FromCache constructs the line directly from the Projection. This eliminates
|
||||
// the per-add HTTP round-trip under steady-state bus-fed conditions for the
|
||||
// common top-level add case. The HTTP path continues to handle:
|
||||
// - cache miss (cold-grace; a SKU not yet bus-fed)
|
||||
// - HasRequiredFields==false (partial bus delivery, e.g. TaxClass missing
|
||||
// because the producer didn't classify)
|
||||
// - parents WITH children (configurator behavior preservation — child
|
||||
// price = child per-m² rate × parent area, and parent area comes from
|
||||
// HTTP-fetched width/height that the Projection doesn't carry yet; a
|
||||
// future schema extension can unblock a child cache-only path).
|
||||
func buildItemGroups(ctx context.Context, items []Item, country string, idx *catalogProjectionCache) []itemGroup {
|
||||
groups := make([]itemGroup, len(items))
|
||||
wg := sync.WaitGroup{}
|
||||
@@ -210,14 +223,27 @@ func buildItemGroups(ctx context.Context, items []Item, country string, idx *cat
|
||||
log.Printf("error adding item %s: bus-deleted (skipping)", itm.Sku)
|
||||
return
|
||||
}
|
||||
parentMsg, parentProduct, err := BuildItemMessage(ctx, itm.Sku, itm.Quantity, country, itm.StoreId, nil)
|
||||
if err != nil {
|
||||
log.Printf("error adding item %s: %v", itm.Sku, err)
|
||||
return
|
||||
|
||||
// Cache-only fast path: see package doc above for the eligibility
|
||||
// contract.
|
||||
var parentMsg *messages.AddItem
|
||||
var parentProduct *ProductItem
|
||||
if len(itm.Children) == 0 && idx != nil {
|
||||
if p, ok := idx.Get(itm.Sku); ok && HasRequiredFields(p) {
|
||||
parentMsg = BuildAddItemFromCache(itm.Sku, itm.Quantity, country, itm.StoreId, p)
|
||||
}
|
||||
}
|
||||
if idx != nil {
|
||||
if p, ok := idx.Get(itm.Sku); ok {
|
||||
ApplyProjectionOverlay(parentMsg, p)
|
||||
if parentMsg == nil {
|
||||
var err error
|
||||
parentMsg, parentProduct, err = BuildItemMessage(ctx, itm.Sku, itm.Quantity, country, itm.StoreId, nil)
|
||||
if err != nil {
|
||||
log.Printf("error adding item %s: %v", itm.Sku, err)
|
||||
return
|
||||
}
|
||||
if idx != nil {
|
||||
if p, ok := idx.Get(itm.Sku); ok {
|
||||
ApplyProjectionOverlay(parentMsg, p)
|
||||
}
|
||||
}
|
||||
}
|
||||
parentMsg.CustomFields = itm.CustomFields
|
||||
|
||||
Reference in New Issue
Block a user