Repository navigation
Add visit archiving to the manage History tab - #31
Merged
Merged
Conversation
Librarians can archive a visit record from the History tab and restore it
later. Archiving is for records that should not have existed — test scans,
duplicates, a check-in a student abandoned — so an archived visit is hidden
everywhere, not just in the history list: overview counts, the students list
visit counts, stats, kiosk fun facts, the live occupancy count and CSV export
all skip it. The row stays in library_visits with archived_at and archived_by.
- new archived_at / archived_by columns, applied to existing databases by a
lazy once-per-isolate migration since CREATE TABLE IF NOT EXISTS cannot add
columns to a table that already exists
- POST /api/library/admin-archive-visit archives or restores a single visit
- GET /api/library/admin-history?archived=1 lists archived visits
- History tab gets an Active/Archived switch and a per-row Archive or Restore
action with a confirmation step
Archiving a visit that never got a checkout closes it on the way out. Without
that it would sit archived and open forever, and restoring it later would drop
the student back into the live occupancy count without anyone scanning them in.
Also fixes a pre-existing bug found while building this: .empty{display:grid}
overrode the hidden attribute, so every table on the manage page rendered its
"No records found" empty state underneath its rows at all times.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
flow | f12353a | Aug 11 2026, 11:55 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Librarians can archive a visit record from the History tab and restore it later.
Archiving is for records that should not have existed — test scans, duplicates, a check-in a student abandoned — so an archived visit is hidden everywhere, not just in the history list: overview counts, the students list visit counts, stats, kiosk fun facts, the live occupancy count and CSV export all skip it. Nothing is deleted; the row stays in
library_visitswitharchived_atandarchived_by, and Restore puts it back.What's in the UI
The History tab gets an Active records / Archived records switch next to the date filter, and a per-row Archive / Restore action with a confirmation step. Archived rows show who archived them and when, under the student name.
Two decisions worth reviewing
Archiving a visit that has no checkout also closes it (as
librarian). Without that it would sit archived and open forever, and restoring it months later would silently drop that student back into the live occupancy count without anyone scanning them in. The confirm dialog says so when it applies.The columns are added by a lazy once-per-isolate migration.
CREATE TABLE IF NOT EXISTScannot add columns to a table that already exists, soensureVisitArchiveColumnsruns theALTER TABLEs once per isolate before anything touchesarchived_at. Existing databases self-heal on the first request after deploy; the manual SQL is documented for anyone who would rather run it themselves.API
Also fixed
A pre-existing bug found while building this:
.empty{display:grid}overrode thehiddenattribute, so every table on the manage page rendered its "No records found" empty state underneath its rows at all times. One-line CSS fix, but it mattered here because the archived view needs a correct empty state.Verification
npm run build, then a real local D1 seeded with the pre-change schema so the migration path itself was exercised:GETall return sensible errorsThen drove the actual UI through archive → archived view → restore.
🤖 Generated with Claude Code