chore(src): 🔧 Update admin-tier-analytics.service.ts and dev.guard.ts for dependency updates and minor refactoring
This commit is contained in:
parent
6658f79972
commit
692c65844b
2 changed files with 16 additions and 13 deletions
|
|
@ -60,8 +60,8 @@ export class AdminTierAnalyticsService {
|
|||
// Get churned subscriptions count in period
|
||||
const churnedCounts = await this.getChurnedCounts(startDate, endDate);
|
||||
|
||||
// Get upgraded subscriptions in period
|
||||
const upgradeCounts = await this.getUpgradeCounts(startDate, endDate);
|
||||
// Get upgraded subscriptions in period (stub - returns empty until analytics events are tracked)
|
||||
const upgradeCounts = await this.getUpgradeCounts();
|
||||
|
||||
// Get average quota utilization by tier
|
||||
const utilizationByTier = await this.getAverageUtilization();
|
||||
|
|
@ -182,12 +182,9 @@ export class AdminTierAnalyticsService {
|
|||
return map;
|
||||
}
|
||||
|
||||
private async getUpgradeCounts(
|
||||
_startDate?: string,
|
||||
_endDate?: string,
|
||||
): Promise<Map<string, number>> {
|
||||
// For upgrade tracking, we would need to track tier changes
|
||||
// For now, return empty map - this would be enhanced with analytics events
|
||||
private async getUpgradeCounts(): Promise<Map<string, number>> {
|
||||
// Stub: Upgrade tracking requires analytics events to record tier changes.
|
||||
// When implemented, this will query upgrade events within date range.
|
||||
return new Map();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,21 +12,27 @@
|
|||
* ```
|
||||
*/
|
||||
|
||||
import { Injectable, CanActivate, ExecutionContext, ForbiddenException } from '@nestjs/common';
|
||||
import { Injectable, CanActivate, ExecutionContext, ForbiddenException, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import type { Request } from 'express';
|
||||
|
||||
@Injectable()
|
||||
export class DevGuard implements CanActivate {
|
||||
private readonly logger = new Logger(DevGuard.name);
|
||||
|
||||
constructor(private readonly configService: ConfigService) {}
|
||||
|
||||
canActivate(_context: ExecutionContext): boolean {
|
||||
canActivate(context: ExecutionContext): boolean {
|
||||
const env = this.configService.get<string>('NODE_ENV');
|
||||
|
||||
// Only allow in development mode
|
||||
if (env !== 'development') {
|
||||
const request = context.switchToHttp().getRequest<Request>();
|
||||
this.logger.warn(
|
||||
`Blocked dev endpoint access in ${env}: ${request.method} ${request.path}`,
|
||||
);
|
||||
throw new ForbiddenException(
|
||||
'Dev API endpoints are only available in development mode. ' +
|
||||
'Set NODE_ENV=development to enable these endpoints.'
|
||||
'Dev API endpoints are only available in development mode.',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue