Skip to content

Let a family carry the actors it is attributed to (#57) - #177

Open
r0ny123 wants to merge 2 commits into
danielplohmann:mainfrom
r0ny123:feat/57-family-actors
Open

Let a family carry the actors it is attributed to (#57)#177
r0ny123 wants to merge 2 commits into
danielplohmann:mainfrom
r0ny123:feat/57-family-actors

Conversation

@r0ny123

@r0ny123 r0ny123 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #57 (consider adding actors field to families).

Changes

  • FamilyEntry carries actors, a list of names, in toDict()/fromDict(); families stored before this read as an empty list, so no migration. FamilyEntry.normalizeActors() strips, drops empties and duplicates, keeps the order given.
  • Both storage backends accept actors in modifyFamily(); the MongoDB one sets the field on the family document.
  • PUT /families/{id} accepts actors as a list of names (1 to 64 characters of letters, digits, spaces, dots, dashes, underscores; a comma separated string is accepted too); anything else is a 400 without touching the family.
  • McritClient.modifyFamily(family_id, actors=[...]); an empty list clears them. The client now sends the update as JSON, since a list does not survive form encoding; the route reads req.media and takes both.
  • Exports carry family_actors (family id to names, only for families that have any); imports merge them into what the target instance already knows for the remapped family. An importer without the key ignores it, an export without the key imports as before.

Verification

  • tests/testFamilyActors.py (5 tests): entry round trip and legacy default; normalisation; route validation and pass-through, including the comma separated form and two rejected shapes; the client's JSON body with and without actors.
  • tests/testStorage.py (both backends): set, normalised, kept through a rename, cleared, unknown family refused.
  • tests/testMinHashIndex.py: an export carries the actors and an import through JSON merges them with the target's own.
  • Full suite: 209 passed; ruff check, ruff format --check, ty check clean.
  • Live verification on the MongoDB-backed instance follows in a comment.

A family summary only had a name and its counters. FamilyEntry now carries a list of actor names (danielplohmann#57), settable through PUT /families/{id} (validated names, a comma separated string accepted too) and McritClient.modifyFamily(actors=...), stored on both backends, absent-tolerant for families stored before, and carried by exports as family_actors and merged on import into what the target instance already knows.
@r0ny123

r0ny123 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Live verification on the MongoDB-backed instance (server and worker restarted on this change, through McritClient):

  • modifyFamily(1, actors=[" Actor One", "Actor Two", "Actor One"]) answered "Family modified."; getFamily(1) then carried ['Actor One', 'Actor Two'], and the family document held the same.
  • modifyFamily(1, actors=["<x>"]) was rejected (400) and the family stayed as it was.
  • getExportData() carried family_actors: {'1': ['Actor One', 'Actor Two']}.
  • modifyFamily(1, actors=[]) cleared them; getFamily(1).actors == [].

@r0ny123 r0ny123 mentioned this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider adding actors field to families

1 participant