Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -591,9 +591,10 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
|
||||
if err := rows.Scan(&colorCode, &dim1Code, &dim3Code); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Resolve to PG dim ids. For this installation we align with PG's authoritative mmitem_dim model:
|
||||
// - dim1 corresponds to mmitem_dim.val1 (typically Color).
|
||||
// - dim3 corresponds to mmitem_dim.val2 (typically Size).
|
||||
// Resolve to PG dim ids. For this installation we align with mmitem_dim key:
|
||||
// - dim1 = color
|
||||
// - dim3 = itemdim3 (optional)
|
||||
// Size (ItemDim1Code) is not part of the key here.
|
||||
d1 := int64(0)
|
||||
if id, ok := resolveDimvalFromToken(pgTx, "dimval1", colorCode); ok {
|
||||
d1 = id
|
||||
@@ -609,11 +610,8 @@ DO UPDATE SET dim_id = EXCLUDED.dim_id, updated_at = EXCLUDED.updated_at
|
||||
continue
|
||||
}
|
||||
var d3 sql.NullInt64
|
||||
// dim3 corresponds to mmitem_dim.val2 (usually ItemDim1Code).
|
||||
if id, ok := resolveDimvalFromToken(pgTx, "dimval1", dim1Code); ok {
|
||||
d3 = sql.NullInt64{Int64: id, Valid: true}
|
||||
resolvedDim3++
|
||||
} else if id, ok := resolveDimvalFromToken(pgTx, "dimval1", dim3Code); ok {
|
||||
// dim3 corresponds to mmitem_dim.val3 (ItemDim3Code).
|
||||
if id, ok := resolveDimvalFromToken(pgTx, "dimval1", dim3Code); ok {
|
||||
d3 = sql.NullInt64{Int64: id, Valid: true}
|
||||
resolvedDim3++
|
||||
}
|
||||
@@ -720,15 +718,14 @@ WHERE mmitem_id = $1
|
||||
if !v1.Valid || v1.Int64 <= 0 {
|
||||
continue
|
||||
}
|
||||
// Variant key in this installation: (val1=color, val3=itemdim3_if_any). Ignore val2 (size).
|
||||
d1 := v1.Int64
|
||||
_ = mmdimID
|
||||
_ = v2
|
||||
|
||||
var d3 sql.NullInt64
|
||||
// In production data we've observed the variant key as (val1, val2). val3 may exist but is not
|
||||
// used as the second axis for pricing/campaign matching in this app.
|
||||
_ = mmdimID
|
||||
_ = v3
|
||||
if v2.Valid && v2.Int64 > 0 {
|
||||
d3 = sql.NullInt64{Int64: v2.Int64, Valid: true}
|
||||
if v3.Valid && v3.Int64 > 0 {
|
||||
d3 = sql.NullInt64{Int64: v3.Int64, Valid: true}
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("%d|%d", d1, func() int64 {
|
||||
|
||||
Reference in New Issue
Block a user