Skip to content

feat: notification digest batching, creators search, postgres backup drill, rate-limit tests - #795

Merged
aji70 merged 4 commits into
MyFanss:mainfrom
kelly-musk:feat/issues-728-730-731-740
Apr 23, 2026
Merged

feat: notification digest batching, creators search, postgres backup drill, rate-limit tests#795
aji70 merged 4 commits into
MyFanss:mainfrom
kelly-musk:feat/issues-728-730-731-740

Conversation

@kelly-musk

Copy link
Copy Markdown
Contributor

Summary

Closes #740, #731, #730, #728


#740 — Notification digest batching

Reduces noise by collapsing repeated same-type events within a 5-minute window into a single notification instead of creating one per event.

Backend

  • NotificationsService: added foldIntoDigest / openDigestWindow — second enqueue within the window updates the existing notification's count/title/body in-place
  • buildSubscriptionLifecycleTemplate accepts digestCount and returns plural titles ("3 subscriptions renewed")
  • Notification entity: new digest_count (int, default 1) and digest_event_times (jsonb) columns
  • Migration: 1745100000000-AddDigestColumnsToNotifications
  • Email only sent for the first event in a window

Frontend

  • NotificationItem: count pill badge when digest_count > 1
  • NotificationDetail: "N events batched" section with individual timestamps
  • Mock data updated with realistic digest examples

Tests

  • 5 new unit tests: plural template titles, fold with no/open/expired window, missing notification, second enqueue folding
  • 2 new e2e tests: digest badge visible in list, digest detail modal shows batched events

#731 — Creators search by handle/display name

Backend

  • Fixed broken searchCreators (dead code after early return, no q filter applied, wrong pagination shape)
  • Now applies LOWER(display_name) LIKE :search OR LOWER(username) LIKE :search prefix match
  • Page-based skip/take pagination, ordered by username ASC
  • PaginatedResponseDto extended with total, page, totalPages fields

Frontend

  • New frontend/src/lib/api/creators.tssearchCreators({ q?, page?, limit? })
  • DiscoverContent calls real API when NEXT_PUBLIC_USE_CREATORS_API=true, falls back to mock otherwise

Tests

  • Existing creators.service.spec.ts tests now pass (they were written against the intended behavior)

#730 — Postgres backup / restore drill

  • scripts/pg-backup-restore.sh: backup, restore, and drill subcommands
    • drill: backup → restore into temp DB → row-count verification → auto-cleanup
    • Password via PGPASSWORD (never on CLI)
  • docs/POSTGRES_BACKUP_RESTORE.md: runbook with pre-deploy checklist, restore decision tree, security notes
  • CI: new db-backup-drill job in .github/workflows/ci.yml (runs after backend-migrations)

#728 — Rate limit integration tests

  • backend/test/rate-limit.e2e-spec.ts: self-contained e2e suite using the real ThrottlerGuard with stub controllers and tiny limits (2–5) for fast, deterministic 429 triggering
    • Auth endpoints → 429 after limit exceeded
    • Health endpoints → never throttled (10 requests all 200)
    • General endpoint (long tier) → 429 after limit
    • 429 response shape: statusCode, message, Retry-After header
  • Fixed latent bug: auth throttle tier was used in @Throttle({ auth: ... }) decorators but never registered in ThrottlerModule.forRoot — added { name: 'auth', ttl: 60000, limit: 5 }

Files changed

File Change
backend/src/notifications/notifications.service.ts Digest batching logic
backend/src/notifications/entities/notification.entity.ts digest_count, digest_event_times columns
backend/src/notifications/dto/notification.dto.ts digest fields in CreateNotificationDto
backend/src/notifications/1745100000000-AddDigestColumnsToNotifications.ts New migration
backend/src/notifications/notifications.service.spec.ts Digest unit tests
backend/src/migration.datasource.ts Register new migration
frontend/src/lib/notifications.ts Notification type + mock data
frontend/src/components/notifications/NotificationItem.tsx Digest count badge
frontend/src/components/notifications/NotificationDetail.tsx Batched events panel
frontend/e2e/notifications.spec.ts Digest e2e tests
backend/src/creators/creators.service.ts Fixed searchCreators
backend/src/common/dto/paginated-response.dto.ts total/page/totalPages
frontend/src/lib/api/creators.ts New API client
frontend/src/app/discover/DiscoverContent.tsx Wire real API
scripts/pg-backup-restore.sh Backup/restore/drill script
docs/POSTGRES_BACKUP_RESTORE.md Runbook
.github/workflows/ci.yml db-backup-drill CI job
backend/test/rate-limit.e2e-spec.ts Rate limit e2e tests
backend/src/app.module.ts Register auth throttle tier
README.md Link to backup/restore doc

- feat(notifications): digest batching to reduce noise (#740)
  - Add digest_count / digest_event_times columns + migration
  - foldIntoDigest / openDigestWindow in NotificationsService
  - Frontend badge + detail panel for batched notifications

- feat(creators): search by handle/display name (#731)
  - Fix broken searchCreators (dead code, missing q filter, wrong pagination)
  - Add LOWER LIKE prefix match on display_name and username
  - Add PaginatedResponseDto total/page/totalPages fields
  - Frontend API client + DiscoverContent wired to real API

- ops(postgres): backup/restore drill (#730)
  - scripts/pg-backup-restore.sh (backup | restore | drill subcommands)
  - docs/POSTGRES_BACKUP_RESTORE.md runbook
  - CI db-backup-drill job in .github/workflows/ci.yml

- test(rate-limit): throttler guard integration tests (#728)
  - backend/test/rate-limit.e2e-spec.ts covering 429, health exemption,
    Retry-After header, and 429 response shape
  - Fix missing auth throttle tier in app.module.ts ThrottlerModule.forRoot
@drips-wave

drips-wave Bot commented Apr 23, 2026

Copy link
Copy Markdown

@kelly-musk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@aji70
aji70 merged commit eec1439 into MyFanss:main Apr 23, 2026
3 of 9 checks passed
aji70 added a commit that referenced this pull request Apr 30, 2026
feat: notification digest batching, creators search, postgres backup drill, rate-limit tests
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.

Notification digest batching

2 participants