Skip to content

feat(analytics): implement analytics service with optimized metrics aggregation#187

Merged
mijinummi merged 1 commit into
MD-Creative-Production:mainfrom
Francis6-git:feature/create-analytics-service-issue-115
Jun 21, 2026
Merged

feat(analytics): implement analytics service with optimized metrics aggregation#187
mijinummi merged 1 commit into
MD-Creative-Production:mainfrom
Francis6-git:feature/create-analytics-service-issue-115

Conversation

@Francis6-git

Copy link
Copy Markdown
Contributor

Description:
This PR implements a robust Role-Based Access Control (RBAC) system within src/modules/rbac/. It introduces role and permission definitions, a type-safe permission checking utility, and an authorization guard/middleware to protect endpoints from unauthorized access.

Changes Made:

  1. Analytics Service Core
    analytics.service.ts: The core service handling the aggregation of metrics.
  • getAlertMetrics(): Leverages Prisma's native .groupBy operation on the Alert model to compute counts grouped by severity and status.
  • getWatchlistMetrics(): Uses Prisma .groupBy on the Watchlist model to calculate totals for isWallet, isContract, and breakdowns by assetCode.
  • getRiskMetrics(): Returns aggregated (mocked) risk metrics to fulfill the acceptance criteria, as there's no native Risk table yet.
  • getSummary(): An aggregated call fetching all metrics concurrently via Promise.all.
  1. REST Controller
    analytics.controller.ts: Exposes the generated metrics through HTTP endpoints:
  • GET /analytics/summary
  • GET /analytics/alerts
  • GET /analytics/watchlists
  • GET /analytics/risk
  1. NestJS Module Setup
    analytics.module.ts: Packages the controller and service for the Nest application.

Closes #115

@mijinummi mijinummi merged commit 6e8ad60 into MD-Creative-Production:main Jun 21, 2026
11 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 21, 2026
3 tasks
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.

Create Analytics Service

2 participants