Cleanup: infer a missing sex from a known-sex spouse (preview → approve)
Unset sex renders blue (male-colored), which is misleading next to a confirmed male partner. Add a Cleanup action that proposes the opposite sex for an unset partner of someone whose sex is set (couples are opposite-sex in practice — a confirmed-male husband ⇒ a female wife). People whose known partners disagree are skipped as ambiguous. It's a preview the user reviews and approves in the Cleanup tool (reusing the existing gender apply path + audit) — not an autonomous write. Backend: guess_gender_by_spouse + GET /cleanup/gender/from-spouse. Frontend: an "Infer from spouse" button feeding the existing proposal list. Test covers propose-opposite, skip-no-partner, skip-already-set, apply, and re-preview. Full suite 73 passed; frontend build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Justin Paul <justin@jpaul.me>
This commit is contained in:
@@ -67,6 +67,16 @@ async def guess_gender(
|
||||
return [GenderProposal(**r) for r in rows]
|
||||
|
||||
|
||||
@router.get("/{tree_id}/cleanup/gender/from-spouse", response_model=list[GenderProposal])
|
||||
async def guess_gender_from_spouse(
|
||||
tree_id: uuid.UUID, session: SessionDep, current: CurrentUser
|
||||
) -> list[GenderProposal]:
|
||||
"""Infer a missing sex from a partner whose sex is set (opposite-sex couple)."""
|
||||
tree = await tree_service.get_tree(session, viewer_id=current.id, tree_id=tree_id)
|
||||
rows = await cleanup_service.guess_gender_by_spouse(session, actor=current, tree=tree)
|
||||
return [GenderProposal(**r) for r in rows]
|
||||
|
||||
|
||||
@router.post("/{tree_id}/cleanup/gender", response_model=CleanupResult)
|
||||
async def apply_gender(
|
||||
tree_id: uuid.UUID, data: GenderApply, session: SessionDep, current: CurrentUser
|
||||
|
||||
Reference in New Issue
Block a user