-
Notifications
You must be signed in to change notification settings - Fork 224
Enable multi-verse tafsirs across /verses APIs #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: do-staging
Are you sure you want to change the base?
Enable multi-verse tafsirs across /verses APIs #747
Conversation
* allow verse presenters to whitelist both one-verse and n-verse tafsir resources * ensure V4 and QDC verse finders de-dupe rows when combining multiple tafsir joins * add request specs proving single ID, multiple IDs, multi-verse ranges, and duplicate-free results * pin cld3 in Gemfile.lock to match the declared dependency Testing * bundle exec rspec spec/requests/api/v4/verses_tafsirs_spec.rb
WalkthroughThe changes extend tafsir filtering to support multi-verse content. Two new scopes are added to ResourceContent for cardinality-type filtering. Multiple finders and presenters are updated to use a broader scope encompassing both single and multi-verse tafsirs. Query deduplication via Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Presenter
participant Finder
participant DB
Client->>Presenter: fetch_tafsirs request
Presenter->>Presenter: approved_tafsirs.verse_level<br/>(OneVerse + NVerse)
Presenter->>Presenter: .allowed_to_share<br/>(scope chain)
Presenter->>Finder: load_tafsirs(relation)
Finder->>DB: .where().eager_load()<br/>.distinct
DB-->>Finder: tafsir records (deduplicated)
Finder-->>Presenter: tafsir set
Presenter-->>Client: response with tafsirs
Note over Presenter,Finder: verse_level scope now includes<br/>multi-verse (NVerse) content
Note over Finder,DB: .distinct removes join-induced<br/>duplicate records
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
🧰 Additional context used🧬 Code graph analysis (1)spec/requests/api/v4/verses_tafsirs_spec.rb (3)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Add support for returning tafsir content when fetching multiple ayahs—via single ID, multiple IDs, or verse ranges—across the
/versesAPIs.Why
Tafsirs previously worked reliably for single-verse lookups. This extends them to multi-verse queries while preventing duplicate rows when joins are combined.
What’s changed
cld3inGemfile.lockto match the declared dependency.API example
Backward compatibility
Testing
bundle exec rspec spec/requests/api/v4/verses_tafsirs_spec.rbNotes
Summary by CodeRabbit
Bug Fixes
New Features
Tests