Skip to content

Bulk Transcriptions v2

The goal is to add a new endpoint to create transcriptions on a element in bulk, but adding sub elements. It will be set under api/v1/element/<uuid:pk>/transcriptions/bulk/ to ease the serializer integration (instead of using the ElementTranscriptions existing endpoint.

This endpoint should only be available as a POST to create new elements & transcriptions.

Its serializer has those fields:

  • type : an ElementType used to create sub elements. Only one type is allowed per request
  • source: a DataSource id or slug, unique per request too. It cannot be set to manual
  • transcriptions: a list of transcriptions with the following fields:
    • zone: a Polygon describing where the transcription is set on the parent's image
    • transcription: the transcription's value

The endpoint should have the following general logic:

  1. list the ascending paths for the target (top) element
  2. list all the requested zones, and find any existing ones on the target image
  3. if any existing zones is found, find any element with the corresponding requested type & existing zones
  4. bulk create the missing zones. We should have a list of all the zones in memory by now
  5. bulk create the missing elements linked to their zone. We should have a list of all the elements in memory by now
  6. bulk create the element paths for the new elements
  7. bulk create the transcription linked to the elements

The bulk create operations should be set in a transaction.