[Indexer] Active Subscriber Counter: implement cached subscriber coun…#93
Merged
elizabetheonoja-art merged 3 commits intoSubStream-Protocol:mainfrom Mar 25, 2026
Conversation
…t, event ingestion, and stats endpoint (SubStream-Protocol#3)
|
@Skinny001 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! 🚀 |
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.
This pull request introduces a new subscription event system to track and manage creator subscriber counts in a robust and scalable way. It adds a dedicated
subscriptionstable, aSubscriptionServicefor event handling, new API endpoints for subscription events and creator stats, and updates the database schema and logic to cache subscriber counts efficiently. Comprehensive tests for the new functionality are also included.Subscription Event System and API Enhancements
/api/subscription/eventsendpoint to receive and process subscription events (subscribe/unsubscribe/expire) with optional shared secret validation. This endpoint updates the subscription state and cached subscriber counts. [1] [2]/api/creator/:id/statsendpoint to fetch a creator's subscriber count, leveraging the cached value for efficiency.Database Schema and Logic Updates
subscriptionstable to track individual wallet subscriptions per creator, and updated thecreatorstable to include asubscriber_countcolumn for efficient aggregate queries. Methods were added for incrementing, decrementing, and syncing this count. [1] [2] [3]subscriber_countcolumn exists on startup, providing backward compatibility for existing deployments.Subscription Service Implementation
SubscriptionService, an event-driven class that processes subscription events, updates the database, emits events, and optionally appends audit logs. Handles both wallet-specific and generic events. [1] [2] [3]Testing
Cleanup and Refactoring
index.js, consolidating middleware and route setup, and ensuring a single, clean application entry point.These changes lay the groundwork for reliable, event-driven subscription tracking and pave the way for future analytics and auditing features.…t, event ingestion, and stats endpoint (#3)
close #3