Skip to content

Fix meditation locale filtering - #206

Merged
Ardnived merged 4 commits into
mainfrom
fix/202-meditation-locale-filter
Feb 5, 2026
Merged

Ardnived merged 4 commits into
mainfrom
fix/202-meditation-locale-filter

Conversation

@Ardnived

@Ardnived Ardnived commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add filterMeditationsByLocale beforeOperation hook that filters meditations by their locale select field on find and count operations
  • Register the hook on the Meditations collection
  • Fix inaccurate documentation that referenced non-existent beforeFind/beforeCount hooks

How it works

Each meditation belongs to a single locale via a select field (unlike other collections that use PayloadCMS field-level localization). The hook intercepts find and count operations and adds { locale: { equals: <requestedLocale> } } to the where clause.

Skipped for:

  • findByID — always returns the specific document
  • locale=all — returns all meditations regardless of locale
  • Non-read operations (create, update, delete)

Closes #202

Test plan

  • Filters English meditations when locale: 'en'
  • Filters Czech meditations when locale: 'cs'
  • Returns all meditations when locale: 'all'
  • findByID returns document regardless of locale mismatch
  • Count respects locale filtering
  • Preserves existing where clauses (AND logic)
  • Defaults to English when no locale specified

Test Results

  • Integration tests: 538 passed, 1 skipped (pre-existing)
  • Build: ✓ Success

🤖 Generated with Claude Code

Ardnived and others added 4 commits February 5, 2026 11:46
Add beforeOperation hook that filters meditations by their locale
select field on find and count operations. Skips filtering for
findByID (always returns specific document) and locale=all requests.

Closes #202

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests cover: locale-specific find/count, locale=all bypass,
findByID locale mismatch, where clause composition, and
default English locale behavior.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update localization.md and architecture.md to accurately describe
the beforeOperation hook implementation instead of the incorrect
beforeFind/beforeCount references.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

Locale filter not working - non-English locale queries return English meditations

1 participant