Repository navigation
feat(collection): undo imports, save views, guard edits, and attach insurance PDFs - #654
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…prompts in Chrome
📝 Documentation UpdatedI reviewed the changes in this PR and drafted documentation updates in #655, which targets this branch. Merge #655 to add the docs here.
Security notes in the docs: PDFs are stored as BLOBs in No documentation changes were needed for: Suggestions (not done):
Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f35274c1be
ℹ️ 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".
| ); | ||
| CREATE INDEX idx_batches_owner ON import_batches(user_id, kind, id); | ||
| ALTER TABLE firearms ADD COLUMN import_batch_id INTEGER REFERENCES import_batches(id); | ||
| ALTER TABLE ammo_inventory ADD COLUMN import_batch_id INTEGER REFERENCES import_batches(id); |
There was a problem hiding this comment.
Update the CSV round-trip test for import batch metadata
Adding import_batch_id to ammunition rows breaks the existing CSV round-trip test in tests/unit/ammo.import.test.js:113–114: service.list() returns this column, but the test's strip helper does not exclude it, so otherwise identical inventories compare unequal because separate imports have different batch IDs. Running npm test -- --silent confirmed this failure (45 suites passed, one failed). Update the comparison to exclude internal import metadata while retaining the inventory-content assertion.
Useful? React with 👍 / 👎.
| router.get(root + '/imports', (req, res) => { | ||
| const batches = service.batches(req.session.user.id, kind); | ||
| res.render('collection/imports', { kind, batches, entry: null }); | ||
| }); |
There was a problem hiding this comment.
Introduce a controller for the collection HTTP handlers
The new collection feature implements its HTTP handlers directly in the route-registration module, including rendering, response status selection, and redirects, rather than providing a controller. This bypasses the controller/service/repository pattern explicitly required for all new features by the root AGENTS.md. Extract these handlers into a collection controller and keep this module responsible for route and middleware registration.
AGENTS.md reference: AGENTS.md:L59-L59
Useful? React with 👍 / 👎.
| function members(userId, kind, id) { | ||
| const related = kind === 'firearms' ? ['firearm_photos', 'range_sessions', 'maintenance_logs', 'firearm_documents'] | ||
| .map(table => `EXISTS(SELECT 1 FROM ${table} WHERE firearm_id=r.id)`).join(' OR ') : '0'; | ||
| return db.prepare(`SELECT m.record_id, m.label, | ||
| CASE WHEN r.id IS NULL THEN 'Absent' WHEN m.edited OR ${related} THEN 'Keep' ELSE 'Remove' END AS action |
There was a problem hiding this comment.
Move import-undo policy into the collection service
The repository now owns the business policy for which imported records must be preserved, assigns the user-facing Keep/Remove actions, and orchestrates undo based on those decisions; the collection service merely re-exports this implementation. The root AGENTS.md explicitly requires repositories to remain SQL-only and contain no business logic. Move eligibility and undo policy into the service, exposing repository operations that preserve the existing transactional recheck.
AGENTS.md reference: AGENTS.md:L49-L49
Useful? React with 👍 / 👎.
| <a href="/<%= kind %>/import">Back to CSV import</a> | ||
| <h2>Import history</h2> | ||
| <% if (!entry) { %> | ||
| <% if (!batches.length) { %><p>No tracked imports yet. History starts with imports made after this update.</p><% } %> |
There was a problem hiding this comment.
Update user documentation for the new collection tools
This commit adds import undo, saved views, edit guards, and downloadable insurance reports with supporting PDFs, but leaves README.md, docs/index.html, and the website screenshots unchanged. In particular, users are not told that import history only starts after this update or that undo preserves edited records. The root AGENTS.md requires README updates for changes to app usage and website/screenshot updates for user-facing features; document these workflows and limitations alongside the implementation.
AGENTS.md reference: AGENTS.md:L156-L157
Useful? React with 👍 / 👎.
…mpts through Chrome
docs: update documentation for PR #654 changes
|
This PR is included in version 2.10.0 🎉 |
Includes the reporting changes from #651 and targets
mainso the repository’s CI and Docker smoke checks run. The four additions in this PR are listed below.Includes a SQLite migration and integration tests for import undo, document inclusion, authenticated download, and saved views.