Skip to content

feat(data-access): add allByEnrollmentProductCode to SiteCollection#1455

Open
jindaliiita wants to merge 1 commit intomainfrom
edge-live-status
Open

feat(data-access): add allByEnrollmentProductCode to SiteCollection#1455
jindaliiita wants to merge 1 commit intomainfrom
edge-live-status

Conversation

@jindaliiita
Copy link
Contributor

Summary

  • Adds allSiteIdsByProductCode(productCode) to SiteEnrollmentCollection — performs a single PostgREST JOIN query (site_enrollmentsentitlements) to return all site IDs enrolled in a given product code
  • Adds allByEnrollmentProductCode(productCode, options) to SiteCollection — uses the above to scope site fetching to a specific product (e.g. LLMO), then batch-fetches full Site objects with caller-controlled field projection via options.attributes
  • Adds unit tests with 100% coverage for both new methods (9 new test cases across 2 files)

Motivation

Required by the optimize-at-edge-enabled-marking import worker job, which previously fetched all sites via Site.all(). Scoping to LLMO-enrolled sites reduces unnecessary data transfer and in-memory filtering as the DB scales.

Test plan

  • SiteEnrollmentCollectionallSiteIdsByProductCode: falsy input, happy path with data, empty data, null data, DB error
  • SiteCollectionallByEnrollmentProductCode: falsy input, empty site IDs (early return), default options, custom options forwarded to batchGetByKeys
  • All 40 tests in both collection test files pass

🤖 Generated with Claude Code

Adds allSiteIdsByProductCode to SiteEnrollmentCollection and
allByEnrollmentProductCode to SiteCollection, enabling efficient
site fetching scoped to a specific product (e.g. LLMO) using a
single PostgREST JOIN query followed by a batch key lookup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nit23uec
Copy link
Contributor

Free trials dont have entitlement info.

@jindaliiita
Copy link
Contributor Author

jindaliiita commented Mar 21, 2026

Free trials dont have entitlement info.

I am able to see it for site ID 1f09e6f5-ad35-4772-bdbb-c1b19a364c4f and org ID d6bfa68d-c137-4203-acd5-1ac7d2d49d84, but not sure if I am missing something.

[ { "id": "884118b6-9b97-479b-9fd2-5a3d4105c0ff", "organizationId": "d6bfa68d-c137-4203-acd5-1ac7d2d49d84", "productCode": "LLMO", "tier": "FREE_TRIAL", "quotas": { "llmo_trial_prompts": 200, "llmo_trial_prompts_consumed": 0 }, "createdAt": "2026-02-24T18:36:33.536Z", "updatedAt": "2026-02-28T18:43:22.748Z", "updatedBy": "system" } ]

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.

2 participants