Simplify UpdateContext to always persist
Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -162,39 +162,30 @@ func (s OrganizationService) UpdateContext(
|
|||||||
return fmt.Errorf("cannot load organization context: %w", err)
|
return fmt.Errorf("cannot load organization context: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
updated := false
|
|
||||||
|
|
||||||
if req.Product != nil {
|
if req.Product != nil {
|
||||||
organizationContext.Product = *req.Product
|
organizationContext.Product = *req.Product
|
||||||
updated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Architecture != nil {
|
if req.Architecture != nil {
|
||||||
organizationContext.Architecture = *req.Architecture
|
organizationContext.Architecture = *req.Architecture
|
||||||
updated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Team != nil {
|
if req.Team != nil {
|
||||||
organizationContext.Team = *req.Team
|
organizationContext.Team = *req.Team
|
||||||
updated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Processes != nil {
|
if req.Processes != nil {
|
||||||
organizationContext.Processes = *req.Processes
|
organizationContext.Processes = *req.Processes
|
||||||
updated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Customers != nil {
|
if req.Customers != nil {
|
||||||
organizationContext.Customers = *req.Customers
|
organizationContext.Customers = *req.Customers
|
||||||
updated = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if updated {
|
organizationContext.UpdatedAt = time.Now()
|
||||||
organizationContext.UpdatedAt = time.Now()
|
|
||||||
|
|
||||||
if err := organizationContext.Update(ctx, tx, s.svc.scope); err != nil {
|
if err := organizationContext.Update(ctx, tx, s.svc.scope); err != nil {
|
||||||
return fmt.Errorf("cannot update organization context: %w", err)
|
return fmt.Errorf("cannot update organization context: %w", err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user