Skip to content

feat: implement GitHub issue webhooks and Redis caching for contributor cap queries - #506

Merged
FaveTeamz merged 1 commit into
FaveTeamz:mainfrom
yachamdaniel1-alt:main
Jul 30, 2026
Merged

feat: implement GitHub issue webhooks and Redis caching for contributor cap queries#506
FaveTeamz merged 1 commit into
FaveTeamz:mainfrom
yachamdaniel1-alt:main

Conversation

@yachamdaniel1-alt

Copy link
Copy Markdown
Contributor

Summary

This pull request introduces two backend improvements focused on scalability and synchronization:

The changes add Redis caching for frequently accessed Soroban contract queries and implement GitHub webhook processing to keep backend issue state synchronized with GitHub in near real time.

These improvements reduce unnecessary RPC traffic, improve application responsiveness under load, and ensure issue assignment data remains consistent with GitHub.


Issue #294 – Redis caching for contributor cap queries

Background

Every issue card render previously triggered multiple read-only Soroban contract queries for contributor limits.

Under moderate or heavy traffic this created unnecessary load against the Soroban RPC node, increasing latency and producing duplicate requests for identical data.

This PR introduces a lightweight Redis caching layer to reduce repeated contract reads while preserving correctness.

Changes

Redis cache support

Implemented caching for:

  • get_global_application_count
  • get_org_assignment_count

using the existing Redis client.

Cache keys

Global contributor count

cap:global:{contributor}

Organization contributor count

cap:org:{contributor}:{org_id}

Cache lifecycle

  • configurable TTL through
CACHE_TTL_SECONDS

(default 30 seconds)

  • cache miss:

    • query Soroban RPC
    • cache response
    • return value
  • cache hit:

    • return cached value immediately
    • avoid RPC request
  • cache invalidation:

    • invalidate affected cache entries after successful transaction submission

Benefits

  • Significantly fewer Soroban RPC requests
  • Lower response latency
  • Reduced RPC load during peak traffic
  • Improved scalability

Issue #295 – GitHub webhook handler

Background

The backend must stay synchronized with GitHub issue activity so dashboards, contributor assignments, and review workflows accurately reflect repository state.

Previously this synchronization depended on polling or manual updates.

This PR introduces a GitHub webhook endpoint that reacts to issue events as they occur.

Changes

New webhook endpoint

POST /api/webhooks/github

Security

Implemented verification of GitHub webhook signatures using:

  • HMAC SHA-256
  • X-Hub-Signature-256

Invalid signatures return:

401 Unauthorized

Supported events

Implemented handling for:

  • issues.opened
  • issues.closed
  • issues.labeled
  • issues.unlabeled
  • issues.assigned

Event behavior

issues.closed

  • locate active assignments
  • update assignment status to:
pending-review

issues.labeled

When the label is:

good first issue

the issue is inserted or updated in the backend database so it becomes visible on the contributor dashboard.

issues.unlabeled

If removal of the label causes the issue to become ineligible:

  • remove it from the dashboard

Unknown events

Unsupported webhook events are acknowledged with:

HTTP 200

without further processing.

Benefits

  • Near real-time synchronization with GitHub
  • Consistent assignment state
  • Automatic dashboard updates
  • Safe handling of unsupported webhook events

Testing

Validation included:

Redis cache

  • cache hit path
  • cache miss path
  • TTL behavior
  • cache invalidation after successful transactions
  • mocked Redis client

GitHub webhook

  • valid signature
  • invalid signature (401)
  • issues.closed
  • issues.labeled
  • issues.unlabeled
  • issues.assigned
  • unknown events

All automated tests pass successfully.


Backwards Compatibility

These changes are fully backward compatible.

  • No public APIs were removed.
  • Existing application behavior is preserved.
  • Unsupported webhook events continue to return HTTP 200.
  • Cache expiration remains configurable through environment variables.

Performance Impact

This PR substantially reduces repeated Soroban RPC reads for contributor cap lookups while maintaining fresh data through short-lived caching and explicit invalidation after successful transactions.

Webhook-driven synchronization also removes the need for periodic polling, reducing unnecessary backend work.


Checklist

  • Redis caching implemented
  • Configurable cache TTL
  • Cache invalidation implemented
  • GitHub webhook endpoint added
  • HMAC signature verification implemented
  • Supported issue events handled
  • Unknown events return HTTP 200
  • Unit tests added
  • Acceptance criteria satisfied

Issues Resolved

Closes #294

Closes #295

@FaveTeamz
FaveTeamz merged commit ddfd5ed into FaveTeamz:main Jul 30, 2026
7 of 23 checks passed
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.

Implement GitHub webhook handler for issue events Add Redis caching layer for contributor cap queries

2 participants