Skip to content

[Indexer] Active Subscriber Counter: implement cached subscriber coun…#93

Merged
elizabetheonoja-art merged 3 commits intoSubStream-Protocol:mainfrom
Skinny001:feature/indexer-active-subscriber-counter
Mar 25, 2026
Merged

[Indexer] Active Subscriber Counter: implement cached subscriber coun…#93
elizabetheonoja-art merged 3 commits intoSubStream-Protocol:mainfrom
Skinny001:feature/indexer-active-subscriber-counter

Conversation

@Skinny001
Copy link
Copy Markdown
Contributor

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 subscriptions table, a SubscriptionService for 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

  • Added a new /api/subscription/events endpoint 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]
  • Introduced a /api/creator/:id/stats endpoint to fetch a creator's subscriber count, leveraging the cached value for efficiency.

Database Schema and Logic Updates

  • Added a subscriptions table to track individual wallet subscriptions per creator, and updated the creators table to include a subscriber_count column for efficient aggregate queries. Methods were added for incrementing, decrementing, and syncing this count. [1] [2] [3]
  • Implemented logic to ensure the subscriber_count column exists on startup, providing backward compatibility for existing deployments.

Subscription Service Implementation

  • Created 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

  • Added tests for subscription event handling and stats retrieval, using an in-memory mock database to verify increment/decrement logic and endpoint behavior.

Cleanup and Refactoring

  • Removed duplicate or obsolete code from 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

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 25, 2026

@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! 🚀

Learn more about application limits

@elizabetheonoja-art elizabetheonoja-art merged commit 836b2a0 into SubStream-Protocol:main Mar 25, 2026
1 check failed
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.

#3 Issue: [Indexer] Active Subscriber Counter

2 participants