8000 fix(verses-api): support multi-verse tafsirs in verses endpoint & Fix eager loading for chapter reciters by basit3407 · Pull Request #718 · quran/quran.com-api · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(verses-api): support multi-verse tafsirs in verses endpoint & Fix eager loading for chapter reciters #718

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

Open
wants to merge 5 commits into
base: do-staging
Choose a base branch
from

Conversation

basit3407
Copy link
@basit3407 basit3407 commented Jun 3, 2025

This PR enables support for multi-verse tafsirs in the /verses/by_key endpoint.

🔧 Fix Summary:

  • Removes the .one_verse constraint from VersesPresenter tafsir filtering logic.
  • Adds load_tafsirs method in VerseFinder, which joins tafsirs by checking whether the verse's id falls between start_verse_id and end_verse_id.
  • Prepares the system to support tafsirs like Ibn Kathir (ID 169), which span multiple verses (e.g., 2:1–2:5).
  • Keeps tafsir loading conditional using params[:tafsirs], avoiding overhead on unrelated endpoints.

Summary for list chapters API

  • eager load recitations' own translated names
  • add regression test for chapter_reciters endpoint

✅ Implementation Notes:

  • The verse-to-tafsir join is now range-aware.
  • Local testing was limited to basic verse lookups (/v4/verses/by_key/2:2?tafsirs=169) without verifying multi-verse coverage due to absence of full DB dump.
  • Logic is in place and should work as expected once start_verse_id and end_verse_id are populated in production/staging.

basit3407 added 5 commits June 3, 2025 10:43
This commit fixes the issue where multi-verse tafsirs (such as ID 169)
were not being returned by the /verses endpoint.

Key change:
- Remove the `one_verse` constraint from the verses presenter, allowing the endpoint
  to include tafsirs that span multiple verses.

This change enables tafsir resources like Ibn Kathir (ID 169) to be properly included in API responses.
via verse ID range join

- Introduced support for multi-ayah tafsir loading in VerseFinder
- Added load_tafsirs method to join tafsirs based on verse ID range (start_verse_id to end_verse_id)
- Ensured single-ayah tafsir continues to work as expected
- Maintains backward compatibility while enabling richer tafsir rendering across APIs like /v4/verses/by_key
…with-eager_load

Fix eager loading for chapter reciters
@basit3407 basit3407 changed the title fix(verses-api): support multi-verse tafsirs in verses endpoint fix(verses-api): support multi-verse tafsirs in verses endpoint & Fix eager loading for chapter reciters Jun 5, 2025
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.

1 participant
0