feat: add CRUD operations for notifications_sent table

Implement MarkNotificationSent, IsNotificationSent, and
GetUnnotifiedReleases with LEFT JOIN query. Includes 10
table-driven tests covering success, error, idempotent,
and edge cases. Also go fmt cleanup on existing files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 09:27:08 +03:00
parent 3b87bfce96
commit 68660e4d83
5 changed files with 354 additions and 20 deletions

View File

@@ -107,12 +107,12 @@ Build the foundation layer of NaviWatcher: a greenfield Go project with zero exi
- [x] run tests — must pass before task 6
### Task 6: Database layer — CRUD operations for notifications_sent
- [ ] implement `MarkNotificationSent(db *DB, rgid string) error`
- [ ] implement `IsNotificationSent(db *DB, rgid string) (bool, error)`
- [ ] implement `GetUnnotifiedReleases(db *DB) ([]ExternalRelease, error)` — joins external_releases with notifications_sent to find unsent
- [ ] write tests for MarkNotificationSent and IsNotificationSent
- [ ] write tests for GetUnnotifiedReleases (with and without existing notifications)
- [ ] run tests — must pass before task 7
- [x] implement `MarkNotificationSent(db *DB, rgid string) error`
- [x] implement `IsNotificationSent(db *DB, rgid string) (bool, error)`
- [x] implement `GetUnnotifiedReleases(db *DB) ([]ExternalRelease, error)` — joins external_releases with notifications_sent to find unsent
- [x] write tests for MarkNotificationSent and IsNotificationSent
- [x] write tests for GetUnnotifiedReleases (with and without existing notifications)
- [x] run tests — must pass before task 7
### Task 7: Docker setup
- [ ] create `Dockerfile` with multi-stage build: build stage (golang:1.21-alpine) + runtime stage (alpine:latest)