focusreactive / focusreactive/payload-plugins

translator: get-collection-status should return document id and target locale, not just job id

Open Beginner friendly
#103 0 comments 0 reactions 0 assignees View on GitHub
enhancement translator
Dominant language
TypeScript
Stars
19
Forks
0
Avg merge
16h 54m
Merged PRs (30d)
19

Description

Read against **0.10.1**.

## Problem

`GET /api/translate/collection/:collection_slug` is the only collection-wide status endpoint, and its
response cannot be keyed to anything.

The runner's normalized `Task` carries what a caller needs: `collectionId`, `targetLng`, timestamps,
error, cancelled. The handler then maps it down to:

```js
tasks.map(task => ({ id: task.id, status }))
```

where `task.id` is the **job id**. Document id and target locale are discarded at the response
boundary.

The scope is right — it calls `runner.findByCollection(collectionSlug)` with no document filter, so
under the payload-jobs runner it does include queued-but-not-yet-run jobs. It is only the response
shape that makes it unusable.

## Why this matters

We wanted this as the queue view for an admin dashboard: "what is in flight across this collection".
With job ids only, there is no way to render "the French translation of page 42 is running". The
alternative is `get-document-status`, which returns the full per-locale shape but is per-document, so
composing a collection queue from it is one request per document.

Correlating job ids back to documents would mean reading `payload-jobs` rows directly, which is
plugin-internal and something we would rather not depend on.

## Suggested shape

Include the fields the `Task` already has:

```js
tasks.map(task => ({
id: task.id,
collectionId: task.collectionId,
targetLng: task.targetLng,
status,
}))
```

The data is already there. This is a response-mapping change, not new plumbing.

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the handler for GET /api/translate/collection/:collection_slug and inspect how runner.findByCollection(collectionSlug) maps each normalized Task into the response. Preserve the job id and status while including collectionId and targetLng, then verify the collection-wide response identifies each document and target locale.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.