Migrate callers from attach-child/detach-child to relate/unrelate API
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s
Switch all cross-service relation calls to the new registry-aware relate/unrelate/can-relate actions, and consolidate per-service container-nav fragment fetches into the generic relations handler. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,9 +93,11 @@ class SqlMarketService:
|
||||
existing.deleted_at = None # revive
|
||||
existing.name = name
|
||||
await session.flush()
|
||||
await call_action("relations", "attach-child", payload={
|
||||
"parent_type": container_type, "parent_id": container_id,
|
||||
"child_type": "market", "child_id": existing.id,
|
||||
await call_action("relations", "relate", payload={
|
||||
"relation_type": f"{container_type}->market",
|
||||
"from_id": container_id, "to_id": existing.id,
|
||||
"label": existing.name,
|
||||
"metadata": {"slug": existing.slug},
|
||||
})
|
||||
return _mp_to_dto(existing)
|
||||
raise ValueError(f'Market with slug "{slug}" already exists for this container.')
|
||||
@@ -106,9 +108,11 @@ class SqlMarketService:
|
||||
)
|
||||
session.add(market)
|
||||
await session.flush()
|
||||
await call_action("relations", "attach-child", payload={
|
||||
"parent_type": container_type, "parent_id": container_id,
|
||||
"child_type": "market", "child_id": market.id,
|
||||
await call_action("relations", "relate", payload={
|
||||
"relation_type": f"{container_type}->market",
|
||||
"from_id": container_id, "to_id": market.id,
|
||||
"label": market.name,
|
||||
"metadata": {"slug": market.slug},
|
||||
})
|
||||
return _mp_to_dto(market)
|
||||
|
||||
@@ -130,8 +134,8 @@ class SqlMarketService:
|
||||
|
||||
market.deleted_at = utcnow()
|
||||
await session.flush()
|
||||
await call_action("relations", "detach-child", payload={
|
||||
"parent_type": container_type, "parent_id": container_id,
|
||||
"child_type": "market", "child_id": market.id,
|
||||
await call_action("relations", "unrelate", payload={
|
||||
"relation_type": f"{container_type}->market",
|
||||
"from_id": container_id, "to_id": market.id,
|
||||
})
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user