fix
This commit is contained in:
@@ -237,6 +237,13 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nameByUID := make(map[string]string, len(insUIDs))
|
||||
for i, uid := range insUIDs {
|
||||
if i < len(insNames) {
|
||||
nameByUID[uid] = insNames[i]
|
||||
}
|
||||
}
|
||||
var seedFormulas []DefaultFormulaTarget
|
||||
for rows.Next() {
|
||||
var id uuid.UUID
|
||||
var uid, path string
|
||||
@@ -246,6 +253,7 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
|
||||
return err
|
||||
}
|
||||
known[uid] = categoryPathInfo{id: id, path: path, level: level}
|
||||
seedFormulas = append(seedFormulas, DefaultFormulaTarget{ID: id, UniqueID: uid, Name: nameByUID[uid]})
|
||||
res.Created++
|
||||
}
|
||||
err = rows.Err()
|
||||
@@ -253,6 +261,11 @@ func (s *Service) flushCategoryBatch(ctx context.Context, companyID uuid.UUID, b
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Imported categories get the platform-default formula too, so an imported
|
||||
// taxonomy enhances into formula-shaped copy without further setup.
|
||||
if err := ApplyDefaultCategoryFormulas(ctx, tx, companyID, seedFormulas...); err != nil {
|
||||
return err
|
||||
}
|
||||
pendingInserts = next
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user