Skip to content

Backend: Add segment_id field to subtasks endpoints #533

@Tech-lo

Description

@Tech-lo

Need to update existing endpoints by adding segment_id (UUID, nullable) parameter to subtasks, similar to how source_text_id and pecha_segment_id were added previously.

Endpoints updated:

1

POST /cms/sub-tasks

Response:

{
  "sub_tasks": [
    {
      "id": "30b676b1-513f-4205-860a-ae8d18613435",
      "content_type": "SOURCE_REFERENCE",
      "content": "Today my life has become fruitful. Having obtained a human existence, I have now been born into the Buddha's family. Today I have become a child of the Buddhas.",
      "duration": "string",
      "image_url": null,
      "source_text_id": "090b3e84-d6a5-49e9-ad8a-ff593f1bd46d",
      "pecha_segment_id": "C28QAKLhnluv37nBX0zPK",
      "segment_id": "d9d743da-5e6c-4da7-8704-3db9403c4550",
      "display_order": 1
    }
  ]
}

2

GET /cms/tasks/{task_id}
{
  "id": "712f7cbe-0e84-4053-b0b4-5229c1d77c8a",
  "title": "NTASK",
  "display_order": 1,
  "estimated_time": 30,
  "subtasks": [
    {
      "id": "30b676b1-513f-4205-860a-ae8d18613435",
      "content_type": "SOURCE_REFERENCE",
      "content": "The appearance of a Buddha, finding faith, obtaining a human life, and having the capacity to practice virtue—these are all so rare. When will such opportunities come together again?",
      "duration": "string",
      "image_url": null,
      "source_text_id": "090b3e84-d6a5-49e9-ad8a-ff593f1bd46d",
      "pecha_segment_id": "AuTye2DWyuDUBANETW6IO",
      "segment_id": "8cc1bbbe-d9b5-413c-a3cd-06b5e8c8086e",
      "display_order": 0
    }
  ]
}

3

PUT /cms/sub-tasks

4

GET /api/v1/plans/{plan_id}/days/{day_number}
{
  "id": "3aacb5e8-28c0-4bf2-9759-fb54d9cadd9f",
  "day_number": 1,
  "tasks": [
    {
      "id": "712f7cbe-0e84-4053-b0b4-5229c1d77c8a",
      "title": "NTASK",
      "estimated_time": 30,
      "display_order": 1,
      "subtasks": [
        {
          "id": "30b676b1-513f-4205-860a-ae8d18613435",
          "content_type": "SOURCE_REFERENCE",
          "content": "The appearance of a Buddha, finding faith, obtaining a human life, and having the capacity to practice virtue—these are all so rare. When will such opportunities come together again?",
          "display_order": 0,
          "source_text_id": "090b3e84-d6a5-49e9-ad8a-ff593f1bd46d",
          "pecha_segment_id": "AuTye2DWyuDUBANETW6IO",
          "segment_id": "8cc1bbbe-d9b5-413c-a3cd-06b5e8c8086e"
        }
      ]
    }
  ]
}

5

GET /api/v1/users/me/plan/{plan_id}/days/{day_number}
{
  "id": "3aacb5e8-28c0-4bf2-9759-fb54d9cadd9f",
  "day_number": 1,
  "tasks": [
    {
      "id": "712f7cbe-0e84-4053-b0b4-5229c1d77c8a",
      "title": "NTASK",
      "estimated_time": 30,
      "display_order": 1,
      "is_completed": false,
      "sub_tasks": [
        {
          "id": "30b676b1-513f-4205-860a-ae8d18613435",
          "display_order": 0,
          "is_completed": false,
          "duration": "string",
          "content_type": "SOURCE_REFERENCE",
          "content": "The appearance of a Buddha, finding faith, obtaining a human life, and having the capacity to practice virtue—these are all so rare. When will such opportunities come together again?",
          "source_text_id": "090b3e84-d6a5-49e9-ad8a-ff593f1bd46d",
          "pecha_segment_id": "AuTye2DWyuDUBANETW6IO",
          "segment_id": "8cc1bbbe-d9b5-413c-a3cd-06b5e8c8086e"
        }
      ]
    }
  ],
  "is_completed": false
}

Steps:

  • Add segment_id (UUID, nullable) column to sub_tasks table

  • Update SubTask model to include the new field

  • Update POST and PUT request schemas to accept segment_id

  • Update SubTaskDTO response to return segment_id

  • Create and run Alembic migration for the new column

  • Implementation

  • Testcases

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions