Skip to content

Admin audit: fix slow SQLite writes, remove gallery, route contact through /api#28

Merged
loganlanou merged 2 commits into
mainfrom
fix/admin-sqlite-wal-and-audit
May 27, 2026
Merged

Admin audit: fix slow SQLite writes, remove gallery, route contact through /api#28
loganlanou merged 2 commits into
mainfrom
fix/admin-sqlite-wal-and-audit

Conversation

@loganlanou
Copy link
Copy Markdown
Collaborator

Summary

Full audit of every admin page (Dashboard, Content, Contacts, Users, Settings) using Chrome DevTools, plus the fixes it surfaced. All five pages render correctly; the issues were functional.

  • fix(db): slow writes — content/settings saves took 5–17s. modernc.org/sqlite ignores the mattn-style _journal_mode=WAL/_foreign_keys DSN params, so the DB ran in rollback-journal mode with synchronous=FULL and foreign keys off. Switched to modernc's _pragma=NAME(VALUE) syntax (WAL + busy_timeout + foreign_keys + synchronous=normal). Writes now sub-millisecond.
  • refactor: remove gallery — per decision, removed the gallery entirely (public /gallery, the orphaned /admin/gallery, all /api/gallery* CRUD + handlers, templates, model/converters, static-build output, GalleryCount stat). DB table + sqlc queries left in place (no destructive migration).
  • refactor: contact → /api — the contact form now POSTs to /api/contact, which actually persists (it was a no-op stub; the form used a separate POST /contact). Removed the duplicate POST /contact handler so submissions go through one /api path.
  • fix(admin): sidebar — clear the "Loading…" user placeholder when Clerk isn't configured (e.g. under the dev auth bypass).

Test plan

  • go build ./... + go build -tags dev ./..., go test -race ./... (both tags), golangci-lint run → 0 issues
  • Audited all 5 admin pages via Chrome DevTools — render, no console errors, actions exercised (settings save, contact mark-read/delete with confirm)
  • Settings/content write latency: 5–17s → <1ms (WAL verified: PRAGMA journal_mode=wal)
  • /gallery, /admin/gallery, /api/gallery all return 404
  • Contact saves via POST /api/contact (200); old POST /contact → 405; admin pages all still 200
  • Dashboard renders correctly after removing the gallery stat

🤖 Generated with Claude Code

loganlanou and others added 2 commits May 27, 2026 08:16
modernc.org/sqlite ignores the mattn-style `_journal_mode=WAL` /
`_foreign_keys=on` query params, so the DB was running in rollback-journal
mode with synchronous=FULL and foreign keys OFF. A single content/settings
save took 5-17s under any concurrent access.

Use modernc's `_pragma=NAME(VALUE)` syntax to actually enable
journal_mode(WAL), busy_timeout(5000), foreign_keys(on), synchronous(normal).
Writes drop from seconds to sub-millisecond.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per product decision, remove the gallery entirely and consolidate all form
submissions onto /api routes.

Gallery removal (public + admin):
- Drop routes: GET /gallery, GET /api/gallery, the /admin/gallery redirect,
  and all /admin/api/gallery* CRUD + the gallery image upload route.
- Remove handlers (Gallery, AdminGallery, APIGetGalleryEditForm,
  APICreate/Update/Delete GalleryItem, APIUpdateGallerySortOrder,
  APIUploadImage), the gallery + admin_gallery templates, the GalleryItem
  model/converters, the gallery static-build output, and the GalleryCount
  stat. The DB table and sqlc queries are left in place (no destructive
  migration).

Contact consolidation:
- The contact form now POSTs to /api/contact, which persists via
  CreateContactSubmission and re-renders the page (previously /api/contact
  was a no-op stub and the form used POST /contact). Removed the duplicate
  POST /contact route + ContactSubmit handler.

Also: clear the admin sidebar "Loading..." placeholder when Clerk is not
configured (e.g. under the dev auth bypass) so it doesn't sit there forever.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rowe-tech Building Building Preview, Comment May 27, 2026 1:17pm

@loganlanou loganlanou merged commit 8193548 into main May 27, 2026
2 of 3 checks passed
@loganlanou loganlanou deleted the fix/admin-sqlite-wal-and-audit branch May 27, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant