Skip to content

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

Merged
jindaliiita merged 4 commits intomainfrom
edge-live-status
Mar 25, 2026
Merged

feat(data-access): add allByEnrollmentProductCode to SiteCollection#1455
jindaliiita merged 4 commits intomainfrom
edge-live-status

Conversation

@jindaliiita
Copy link
Copy Markdown
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
Copy Markdown
Contributor

Free trials dont have entitlement info.

@jindaliiita
Copy link
Copy Markdown
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" } ]

@github-actions
Copy link
Copy Markdown

This PR will trigger a minor release when merged.

@jindaliiita
Copy link
Copy Markdown
Contributor Author

Free trials dont have entitlement info.

Yes, they have, confirmed it with @ravverma. @ravverma, please correct me if I am wrong here.

@jindaliiita jindaliiita merged commit 0225791 into main Mar 25, 2026
7 checks passed
@jindaliiita jindaliiita deleted the edge-live-status branch March 25, 2026 05:01
solaris007 pushed a commit that referenced this pull request Mar 25, 2026
## [@adobe/spacecat-shared-data-access-v3.30.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.29.0...@adobe/spacecat-shared-data-access-v3.30.0) (2026-03-25)

### Features

* **data-access:** add allByEnrollmentProductCode to SiteCollection ([#1455](#1455)) ([0225791](0225791))
@solaris007
Copy link
Copy Markdown
Member

🎉 This PR is included in version @adobe/spacecat-shared-data-access-v3.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants