Skip to content

feat: filter whitespace normalization tests, creator detail include c…#239

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Johnsmichael150:main
Apr 28, 2026
Merged

feat: filter whitespace normalization tests, creator detail include c…#239
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Johnsmichael150:main

Conversation

@Johnsmichael150
Copy link
Copy Markdown

Summary

Four focused improvements to the creator list and feed subsystems: test coverage for filter whitespace normalization, centralized include-field constants for creator detail reads, a validated cursor decode helper for the creator feed, and a configurable slow query warning log on the creator list path.


Changes

1. Filter whitespace normalization tests

src/modules/creators/creators.filter.test.ts

Added unit coverage for parseCreatorFilters whitespace handling:

  • leading/trailing whitespace is trimmed
  • internal whitespace collapses to a single space
  • whitespace-only input is dropped (no key in result)
  • unknown filter keys throw with a descriptive message
  • combined verified + search cases

Also aligned parseCreatorFilters to collapse internal whitespace (/\s+/g → ' '), matching the behavior of normalizeCreatorListSearchTerm.


2. Centralized creator detail include-field constants

src/constants/creator-detail-include.constants.ts
src/modules/creator/creator-profile.service.ts

Defined CREATOR_DETAIL_DEFAULT_SELECT as a single source of truth for the Prisma select fields returned on every creator detail read. Applied it in getCreatorProfile to replace the previously implicit full-row fetch. Response shape is backward compatible.


3. Creator feed cursor decode helper

src/utils/creator-feed-cursor.utils.ts

Added decodeCreatorFeedCursor(raw) which wraps the existing decodeCursor utility and:

  • returns a discriminated union { ok: true, payload } | { ok: false, error } so callers avoid try/catch
  • validates that the decoded payload contains the required createdAt and id fields
  • surfaces CursorChecksumError messages directly for consistent API error responses

4. Slow creator list query warning log

src/config.ts
src/modules/creators/creators.utils.ts

Added CREATOR_LIST_SLOW_QUERY_THRESHOLD_MS to the env config schema (default 500ms). When fetchCreatorList exceeds the threshold, a logger.warn fires with sanitized metadata:

{
  msg: 'Slow creator list query',
  durationMs,
  thresholdMs,
  sort,
  order,
  hasSearch,        // boolean — no raw search term logged
  hasVerifiedFilter,
  limit,
  offset
}

Override the threshold via environment variable:

CREATOR_LIST_SLOW_QUERY_THRESHOLD_MS=1000

Files Changed

File Change
src/modules/creators/creators.filter.test.ts new — whitespace normalization tests
src/modules/creators/creators.filter.ts fix — collapse internal whitespace in search
src/constants/creator-detail-include.constants.ts new — CREATOR_DETAIL_DEFAULT_SELECT
src/modules/creator/creator-profile.service.ts refactor — use CREATOR_DETAIL_DEFAULT_SELECT
src/utils/creator-feed-cursor.utils.ts new — decodeCreatorFeedCursor helper
src/config.ts feat — CREATOR_LIST_SLOW_QUERY_THRESHOLD_MS config key
src/modules/creators/creators.utils.ts feat — slow query warning log

Testing

Run existing test suite:

pnpm test

Run filter tests directly:

node_modules/.bin/jest --testPathPatterns="creators.filter.test" --no-coverage

Backward Compatibility

No breaking changes. All response shapes are preserved. The new config key has a safe default.

Linked Issues

Close #235
Close #236
Close #234
Close #233

…onstants, feed cursor helper, slow query warning log
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 27, 2026

@Johnsmichael150 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

@Chucks1093 Chucks1093 merged commit 0dd738a into accesslayerorg:main Apr 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants