Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -284,6 +284,10 @@ func productSeriesProcessQueue(ctx context.Context, pg *sql.DB, batchSize int, a
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, 0, err
|
return 0, 0, 0, err
|
||||||
}
|
}
|
||||||
|
variants, _, err := productSeriesLoadMSSQLStockVariants(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, 0, err
|
||||||
|
}
|
||||||
totalProcessed, totalWritten, totalSkipped := 0, 0, 0
|
totalProcessed, totalWritten, totalSkipped := 0, 0, 0
|
||||||
for {
|
for {
|
||||||
tx, err := pg.BeginTx(ctx, nil)
|
tx, err := pg.BeginTx(ctx, nil)
|
||||||
@@ -303,11 +307,7 @@ func productSeriesProcessQueue(ctx context.Context, pg *sql.DB, batchSize int, a
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, it := range items {
|
for _, it := range items {
|
||||||
variant, ok, err := productSeriesLoadSingleVariant(ctx, it.ProductCode, it.ColorCode, it.Dim3Code)
|
variant, ok := variants[productSeriesAutoKey(it.ProductCode, it.ColorCode, it.Dim3Code)]
|
||||||
if err != nil {
|
|
||||||
_ = productSeriesMarkQueueFailed(ctx, pg, it, err.Error())
|
|
||||||
return totalProcessed, totalWritten, totalSkipped, err
|
|
||||||
}
|
|
||||||
if !ok {
|
if !ok {
|
||||||
variant = productSeriesAutoVariant{
|
variant = productSeriesAutoVariant{
|
||||||
RowKey: productSeriesAutoKey(it.ProductCode, it.ColorCode, it.Dim3Code),
|
RowKey: productSeriesAutoKey(it.ProductCode, it.ColorCode, it.Dim3Code),
|
||||||
@@ -439,16 +439,6 @@ func productSeriesLoadMSSQLStockVariants(ctx context.Context) (map[string]produc
|
|||||||
return out, scanned, nil
|
return out, scanned, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func productSeriesLoadSingleVariant(ctx context.Context, productCode, colorCode, dim3Code string) (productSeriesAutoVariant, bool, error) {
|
|
||||||
variants, _, err := productSeriesLoadMSSQLStockVariants(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return productSeriesAutoVariant{}, false, err
|
|
||||||
}
|
|
||||||
key := productSeriesAutoKey(productCode, colorCode, dim3Code)
|
|
||||||
v, ok := variants[key]
|
|
||||||
return v, ok, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func productSeriesLoadRules(ctx context.Context, pg *sql.DB) ([]productSeriesAutoRule, error) {
|
func productSeriesLoadRules(ctx context.Context, pg *sql.DB) ([]productSeriesAutoRule, error) {
|
||||||
rows, err := pg.QueryContext(ctx, `
|
rows, err := pg.QueryContext(ctx, `
|
||||||
SELECT d.id, COALESCE(d.code,''), COALESCE(d.title,''),
|
SELECT d.id, COALESCE(d.code,''), COALESCE(d.title,''),
|
||||||
|
|||||||
Reference in New Issue
Block a user