fix(classification): harden registration updates
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02b22-9638-76d2-bbff-b7ea1770b118
This commit is contained in:
parent
fb79d0d68d
commit
57c3e08103
7 changed files with 152 additions and 14 deletions
|
|
@ -604,10 +604,27 @@ async def update_repo_with_classification(
|
|||
"""Patch repo metadata including classification spine fields."""
|
||||
repo = await _get_repo_by_slug(slug, session)
|
||||
payload = body.model_dump(exclude_unset=True)
|
||||
domain_result = await session.execute(select(Domain).where(Domain.id == repo.domain_id))
|
||||
domain_obj = domain_result.scalar_one_or_none()
|
||||
requested_domain_slug = payload.pop("domain_slug", None)
|
||||
if requested_domain_slug is not None:
|
||||
domain_result = await session.execute(
|
||||
select(Domain).where(Domain.slug == requested_domain_slug)
|
||||
)
|
||||
domain_obj = domain_result.scalar_one_or_none()
|
||||
if domain_obj is None:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail=f"Domain '{requested_domain_slug}' not found",
|
||||
)
|
||||
else:
|
||||
domain_result = await session.execute(
|
||||
select(Domain).where(Domain.id == repo.domain_id)
|
||||
)
|
||||
domain_obj = domain_result.scalar_one_or_none()
|
||||
domain_slug = domain_obj.slug if domain_obj else ""
|
||||
if classification_fields_set(payload):
|
||||
classification_requested = classification_fields_set(payload)
|
||||
if classification_requested or (
|
||||
requested_domain_slug is not None and repo.category is not None
|
||||
):
|
||||
merged = {
|
||||
"category": payload.get("category", repo.category),
|
||||
"secondary_domains": payload.get("secondary_domains", repo.secondary_domains),
|
||||
|
|
@ -620,6 +637,8 @@ async def update_repo_with_classification(
|
|||
fields=merged,
|
||||
require_complete=True,
|
||||
)
|
||||
if requested_domain_slug is not None:
|
||||
repo.domain_id = domain_obj.id
|
||||
for field, value in payload.items():
|
||||
setattr(repo, field, value)
|
||||
await session.commit()
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class RepoCreate(CoreRepoCreate, ClassificationFields):
|
|||
|
||||
|
||||
class RepoUpdate(ClassificationFields):
|
||||
domain_slug: str | None = None
|
||||
name: str | None = None
|
||||
local_path: str | None = None
|
||||
remote_url: str | None = None
|
||||
|
|
@ -176,4 +177,4 @@ class RepoScopeHealth(BaseModel):
|
|||
local_path: str | None = None
|
||||
path_available: bool
|
||||
scope_needs_review: bool
|
||||
scope_issue_details: list[ScopeIssueDetail]
|
||||
scope_issue_details: list[ScopeIssueDetail]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue