Ft/import export#567
Conversation
Enable data import/export functionality for the "promises" and "ai-extractions" collections via the Payload CMS import-export plugin. This provides administrators with CSV/JSON export capabilities and data import functionality directly from the admin interface.
Introduce a new collection `ai-extraction-export-rows` to provide flattened export data for AI extractions, enabling CSV exports via the import-export plugin. Add hooks to related collections (AIExtractions, Documents, PoliticalEntities, Tenants) to automatically synchronize export rows on changes. Include a migration to backfill existing data, a scheduled task for rebuilding, and comprehensive unit tests. Update package dependencies and fix import ordering.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This workflow was using a third-party action that is no longer needed. Removing it simplifies our CI setup and reduces dependency on external services.
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2dfa0ba191
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add hooks to PromiseStatus collection to trigger resync of AI extraction export rows when a status is updated or deleted. This ensures data consistency between promise statuses and their associated export rows. Implement syncAIExtractionExportRowsForStatus function that finds all export rows linked to a status, identifies unique AI extractions, and triggers resync for each. Update test to verify deduplication behavior and proper payload calls. Also fix unique key generation to use Payload array row IDs instead of uniqueId to handle duplicate uniqueId values, and remove unnecessary eslint-disable comment.
This comment was marked as resolved.
This comment was marked as resolved.
Replace find-then-delete loop with a single delete operation using where clause to improve performance and reduce database round trips.
This comment was marked as resolved.
This comment was marked as resolved.
|
Is this still here @kelvinkipruto ? |
…r export row sync - Wrap all export row sync/delete operations in try-catch blocks with proper error logging - Add background job queuing for tenant and political entity sync operations to improve performance - Pass request context through all sync operations for proper access control - Add indexes to frequently queried fields in AIExtractionExportRows collection - Extend sync task to support tenant and political entity scoped operations
This comment was marked as resolved.
This comment was marked as resolved.
Replace direct sync calls in collection hooks with job queue to defer processing Add batching utility for large collections to prevent memory issues Update rebuild function to delete stale rows instead of clearing all rows
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 848caca6c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This is intended |
…d optimize deletion - Queue sync tasks for tenant and promise status changes/delete operations instead of direct execution - Add support for status-scoped sync in task handler - Optimize stale row deletion in rebuildAllAIExtractionExportRows to use bulk delete operations - Improve error logging messages to reflect queuing behavior
This comment was marked as resolved.
This comment was marked as resolved.
…t rows Add early return when no AI extractions are found during rebuild to avoid unnecessary count and delete operations. Also replace queued job with direct function call for tenant deletion cleanup to ensure immediate removal of associated export rows.
|
@claude Review |
This comment was marked as resolved.
This comment was marked as resolved.
Move inline job queueing logic from collection configs to dedicated hook files Extract shared type definitions and utility functions to central module Add new PromiseStatus collection with sync hooks Create new Documents and AIExtractions collections with sync hooks
|
@claude Review |
This comment was marked as resolved.
This comment was marked as resolved.
Add input validation to ensure scoped sync operations provide the required identifier. Refuse execution when scope is specified but the corresponding ID is missing or when an unsupported scope is provided. Simplify conditional logic in rebuildAllAIExtractionExportRows by removing unnecessary ternary operators, as the condition always evaluates to true in practice.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1eb30896aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… export rows Improve the rebuildAllAIExtractionExportRows function to only delete export rows for AI extractions that are confirmed missing, rather than using a simple not_in check against the synced IDs. This prevents race conditions where export rows created after the rebuild scan started would be incorrectly deleted. Add helper functions aiExtractionExists and findOrphanedAIExtractionIds to verify each candidate AI extraction still exists in the database before marking its export rows for deletion. Also add error logging wrappers to all sync functions to improve debuggability.
|
@claude Review |
|
Claude finished @kelvinkipruto's task in 2m 40s —— View job Code Review
This is a solid implementation overall. The job-queue pattern for async sync, pure builder function, and per-extraction error isolation are all good design choices. Several previous P1 issues from earlier Codex reviews have been fixed (row key now correctly uses Below are the remaining issues I found. P1 — Deleted
|
| Previous P1 | Status |
|---|---|
getExtractionRowId using uniqueId as key |
✅ Fixed — now uses extraction.id first via getId(extraction) |
PromiseStatus changes not syncing export rows |
✅ Fixed — PromiseStatus hooks are wired |
| Transaction ID not threaded through | ✅ N/A — sync is now async via job queue, so it correctly runs outside the originating transaction |
| Status-scoped sync aborting on missing extraction | ✅ Fixed — each extraction sync is wrapped in try/catch |
| Locale nondeterminism | Intentional per author |
| Tenant rows deleted vs. rebuilt | Still unresolved (P1 above) |
Description
Add ability to export AI extractions as CSV.
Fixes # (issue)
Type of change
Screenshots
Checklist: