Skip to content

Add batch homework completion API #37

@tiankaima

Description

@tiankaima

Problem

Bot users can complete or undo multiple homework items at once, but the bot currently loops over targets and calls PUT /api/homeworks/:id/completion once per homework.

That means multi-select operations are slow, partially successful states are harder to report consistently, and authorization/existence checks are duplicated per request.

Proposed server-side feature

Add a batch endpoint, for example:

PUT /api/homeworks/completions

Request shape idea:

{ "items": [{ "homeworkId": "...", "completed": true }] }

Response shape should report per-item result:

  • success/failure,
  • homework ID,
  • completed state,
  • completedAt when applicable,
  • not-found / forbidden / deleted errors per item.

References

Existing single-item endpoint: src/routes/api/homeworks/[id]/completion/+server.ts and src/lib/api/routes/homework-completion.ts.

Server MCP has set_my_homework_completion, also single-item, in src/lib/mcp/tools/my-data-tools.ts.

Bot currently batches client-side in internal/commands/commands.go setHomeworkCompletionBatch.

Acceptance criteria

  • Batch update is atomic where practical, or clearly returns per-item partial results.
  • Single-item endpoint remains compatible.
  • OpenAPI/schema docs include the new request/response.
  • Bot can replace its per-homework loop with one API call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions