Repository navigation
Subscription: paged merchant listing and count views - #136
Open
sylvanus-max wants to merge 5 commits into
Open
sylvanus-max wants to merge 5 commits into
sylvanus-max wants to merge 5 commits into
Conversation
Add get_by_merchant_page(merchant, start, limit), which mirrors the subscriber page view and shares its helper. It reads only one slice of the merchant index. limit is capped at MAX_PAGE_LIMIT (50), and a page past the end is empty. get_by_merchant is kept unchanged. A test checks that pages run end to end with no gaps or repeats, and that a huge limit is capped. Closes stellar-sub#45 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…ar-sub#46) Add count views that return the length of the stored id list, so clients can size a page without downloading every subscription. A test checks that counts match the listings and that a party with none counts zero. Closes stellar-sub#46 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
@sylvanus-max Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
… yet) Both issues are marked "Needs design" and ask for maintainer agreement before any code is written. Add a short proposal for each under docs/design instead: an index of subscriptions by plan for get_by_plan_page and count_by_plan (stellar-sub#47), and a paged due_for_merchant view with a scan cap (stellar-sub#48). Each proposal lists its trade-offs and the questions for maintainers. No contract code is changed. Refs stellar-sub#47 Refs stellar-sub#48 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
…-sub#47) Add a ByPlan index, written at subscribe only for plan subscriptions (plan_id != 0), so ad-hoc subscriptions add no writes. Add get_by_plan_page, which reads one slice of the index with the same paging as the other listings, and count_by_plan, which reads only the index length. Tests cover listing only a plan's own subscriptions in creation order, paging end to end, ad-hoc subscriptions never being indexed, and a plan with no subscriptions. Not backfilled: subscriptions created before this change are not listed by plan. Existing deployments need a migration, which is not included. The version constant from the design proposal is not added on this branch, because the version() entrypoint is not on this branch. Closes stellar-sub#47 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
) Add due_for_merchant(merchant, start, limit), which returns the merchant's subscriptions that is_chargeable reports as due now, and the position to resume from. It walks the merchant's index from start. Each call reads at most MAX_SCAN (200) index entries, so a call can return fewer than limit ids while more remain, and the caller keeps paging until the position is None. limit is clamped to between 1 and MAX_PAGE_LIMIT. Tests cover the due filter, cancelled subscriptions, paging to the end, and the scan cap, where the first 200 entries are cancelled and the due ones are found on the next call. The result is a snapshot, so a charge on a returned id can still fail. Batch charging (stellar-sub#49) is not included. Closes stellar-sub#48 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Subscription: paged and counted listings, plan index, due-subscriptions view
get_by_merchant_page(merchant, start, limit), which reads one slice of the merchant index.limitis capped atMAX_PAGE_LIMIT(50).get_by_merchantis unchanged.count_by_subscriberandcount_by_merchant, which return the index length without loading records.ByPlanindex, written atsubscribeonly for plan subscriptions, plusget_by_plan_pageandcount_by_plan. Not backfilled: subscriptions created before this change are not listed by plan.due_for_merchant(merchant, start, limit), which returns the merchant's due subscriptions and a resume position. Each call reads at mostMAX_SCAN(200) index entries, so a call can return fewer thanlimitids while more remain. The result is a snapshot.docs/design/47-*.mdanddocs/design/48-*.mdare the design proposals this code follows.Closes #45
Closes #46
Closes #47
Closes #48
Notes for review:
🤖 Generated with Claude Code