feat(DCP-2201): Add collection export command#377
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
Adds a new prolific collection export <collection-id> CLI subcommand that drives the async collection export flow exposed by the data-collection-tool backend (initiate export job, poll status, then download the resulting ZIP).
Changes:
- Introduces
collection exportCobra command with polling + ZIP download behavior. - Extends the API client interface and implementation with initiate/poll export endpoints and response type.
- Adds gomock support and new command tests for immediate-complete, polling, and failure paths.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/collection/export.go | New export command implementation (initiate, poll, download). |
| cmd/collection/export_test.go | New unit tests covering cached/immediate completion, polling completion, and failure scenarios. |
| cmd/collection/collection.go | Registers export as a subcommand under collection. |
| client/client.go | Adds API interface methods + client implementations for export initiate/status endpoints. |
| client/responses.go | Adds CollectionExportResponse model for export endpoints. |
| mock_client/mock_client.go | Updates gomock client to support new export methods. |
…th on complete success to avoid partial files on error
cmd/collection/export.go
Outdated
| } | ||
|
|
||
| if opts.Output == "" { | ||
| opts.Output = fmt.Sprintf("%s-export.zip", opts.Args[0]) |
There was a problem hiding this comment.
personal pref territory but what do you think about adding a timestamp to the filename? just thinking for people who download the export multiple times 🤣 they'll end up with %s-export(18).zip after a while
There was a problem hiding this comment.
great suggestion, ty
feat(DCP-2201): add
collection exportcommandcli-collection-export.mp4
Context
The data-collection-tool backend now exposes an async collection export API (DCP-2199 / DCP-2201). When triggered, it generates a ZIP archive containing all submission responses, collection metadata, a README, and any participant-uploaded files. This PR adds the CLI command to drive that flow end-to-end.
What this does
Adds
prolific collection export <collection-id>which:POST /collections/{id}/exportto initiate a new export jobcompleteimmediately and the file is downloaded without pollingGET /collections/{id}/export/{exportId}every 3 seconds until the job iscompleteorfailed(10-minute timeout)API design
The backend API follows RESTful semantics cleanly:
POST/collections/{id}/exportgenerating+export_id(202) orcomplete+url(200 cached)GET/collections/{id}/export/{exportId}generating,complete, orfailed