Skip to content

feat(backend): implement user predictions, event stats, indexer health, and email notifications#912

Merged
Olowodarey merged 3 commits into
Arena1X:mainfrom
testersweb0-bug:feature/backend-apis-731-722-727-749
May 29, 2026
Merged

feat(backend): implement user predictions, event stats, indexer health, and email notifications#912
Olowodarey merged 3 commits into
Arena1X:mainfrom
testersweb0-bug:feature/backend-apis-731-722-727-749

Conversation

@testersweb0-bug
Copy link
Copy Markdown
Contributor

Summary

Implements four backend features for creator events, indexer monitoring, and optional email notifications:

Changes

Creator Events (#731, #727)

  • Added getUserPredictionsForEvent() and getEventStats() to CreatorEventsService
  • Added getEventStatistics() and getPredictionDistribution() wrappers to ContractService
  • Added prediction normalization utility for snake_case/camelCase contract field compatibility
  • Extended ContractPrediction interface with on-chain fields (predicted_at, is_correct, etc.)
  • Registered CacheModule in CreatorEventsModule
  • OpenAPI DTOs: UserPredictionsResponseDto, EventStatsResponseDto

Indexer Health (#722)

  • New IndexerHealthService with metrics aggregation and alert evaluation
  • New IndexerHealthController at /indexer/health/*
  • Extended IndexerService with events-per-minute tracking, manual sync trigger, and last-sync timestamp
  • Prometheus exposition format at /indexer/health/prometheus

Email Notifications (#749)

  • New EmailService with in-memory async queue and per-minute rate limiting
  • HTML email templates for event lifecycle notifications
  • Preference-aware sending via existing user_preferences table
  • SendGrid delivery when SENDGRID_API_KEY is configured; console fallback in dev

New Endpoints

Method Route Auth Cache
GET /api/v1/creator-events/:id/predictions/:address JWT 30s
GET /api/v1/creator-events/:id/stats JWT 120s
GET /api/v1/indexer/health Public
GET /api/v1/indexer/health/dashboard Public
GET /api/v1/indexer/health/prometheus Public
POST /api/v1/indexer/health/sync Admin

Environment Variables (optional)

Variable Purpose
SENDGRID_API_KEY Enable SendGrid email delivery
EMAIL_FROM Sender address (default: notifications@insightarena.app)
EMAIL_RATE_LIMIT_PER_MINUTE Max emails per minute (default: 30)

Test plan

  • Unit tests for prediction normalization and correctness resolution
  • Service tests for user predictions enrichment and score calculation
  • Service tests for event statistics aggregation and completion rate
  • Controller tests for new creator-events endpoints
  • Indexer health service tests (healthy, lag alert, stale sync alert, Prometheus export)
  • Indexer health controller tests
  • Email service tests (queue, opt-out, all template types)
  • pnpm build passes
  • Manual: GET /api/v1/creator-events/:id/predictions/:address against testnet contract
  • Manual: GET /api/v1/creator-events/:id/stats returns expected distribution
  • Manual: GET /api/v1/indexer/health shows accurate lag and alerts
  • Manual: GET /api/v1/indexer/health/prometheus scrapable by Prometheus
  • Manual: POST /api/v1/indexer/health/sync triggers poll (admin JWT)
  • Manual: Email delivery with SENDGRID_API_KEY configured

Closes

…h, and email notifications

Add creator-events prediction and statistics APIs, indexer health monitoring with Prometheus export and alerting, and an optional async email notification service with opt-in preferences support.

Closes Arena1X#731, Arena1X#722, Arena1X#727, Arena1X#749
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment May 29, 2026 11:20pm

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@testersweb0-bug 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

Ensure getPendingMatches handles missing event lookups and oracle unit tests mock eventRepository.find so CI test job passes.
@Olowodarey Olowodarey merged commit 60dd906 into Arena1X:main May 29, 2026
3 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

2 participants