This commit is contained in:
2026-04-16 17:21:48 +03:00
parent c8fa4c442d
commit c8e7e4e927
116 changed files with 3720 additions and 4197 deletions
+19 -19
View File
@@ -6,20 +6,20 @@ import {
HttpCode,
HttpStatus,
ForbiddenException,
} from '@nestjs/common';
} from "@nestjs/common";
import {
ApiTags,
ApiBearerAuth,
ApiOperation,
ApiResponse,
} from '@nestjs/swagger';
import { AnalysisService } from './analysis.service';
import { AnalyzeMatchesDto } from './dto/analysis-request.dto';
import { CurrentUser } from '../../common/decorators';
} from "@nestjs/swagger";
import { AnalysisService } from "./analysis.service";
import { AnalyzeMatchesDto } from "./dto/analysis-request.dto";
import { CurrentUser } from "../../common/decorators";
@ApiTags('Analysis')
@ApiTags("Analysis")
@ApiBearerAuth()
@Controller('analysis')
@Controller("analysis")
export class AnalysisController {
constructor(private readonly analysisService: AnalysisService) {}
@@ -27,12 +27,12 @@ export class AnalysisController {
* POST /analysis/analyze-matches
* Analyze multiple matches (coupon generation)
*/
@Post('analyze-matches')
@Post("analyze-matches")
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Analyze multiple matches for coupon' })
@ApiResponse({ status: 200, description: 'Analysis successful' })
@ApiResponse({ status: 400, description: 'Invalid input' })
@ApiResponse({ status: 429, description: 'Usage limit exceeded' })
@ApiOperation({ summary: "Analyze multiple matches for coupon" })
@ApiResponse({ status: 200, description: "Analysis successful" })
@ApiResponse({ status: 400, description: "Invalid input" })
@ApiResponse({ status: 429, description: "Usage limit exceeded" })
async analyzeMatches(
@CurrentUser() user: any,
@Body() dto: AnalyzeMatchesDto,
@@ -48,7 +48,7 @@ export class AnalysisController {
);
if (!canProceed) {
throw new ForbiddenException('You have exceeded your daily usage limit');
throw new ForbiddenException("You have exceeded your daily usage limit");
}
// Run analysis
@@ -57,7 +57,7 @@ export class AnalysisController {
if (!result) {
return {
success: false,
message: 'None of the provided matches could be analyzed successfully',
message: "None of the provided matches could be analyzed successfully",
};
}
@@ -73,10 +73,10 @@ export class AnalysisController {
/**
* POST /analysis/analyze (alias for /analyze-matches - frontend compatibility)
*/
@Post('analyze')
@Post("analyze")
@HttpCode(HttpStatus.OK)
@ApiOperation({
summary: 'Analyze multiple matches for coupon (alias)',
summary: "Analyze multiple matches for coupon (alias)",
deprecated: true,
})
async analyzeMatchesAlias(
@@ -90,9 +90,9 @@ export class AnalysisController {
* GET /analysis/history
* Get user's analysis history
*/
@Get('history')
@ApiOperation({ summary: 'Get analysis history' })
@ApiResponse({ status: 200, description: 'History retrieved' })
@Get("history")
@ApiOperation({ summary: "Get analysis history" })
@ApiResponse({ status: 200, description: "History retrieved" })
async getHistory(@CurrentUser() user: any) {
const history = await this.analysisService.getAnalysisHistory(user.id);
return { success: true, data: history };
+5 -5
View File
@@ -1,8 +1,8 @@
import { Module } from '@nestjs/common';
import { AnalysisController } from './analysis.controller';
import { AnalysisService } from './analysis.service';
import { DatabaseModule } from '../../database/database.module';
import { ServicesModule } from '../../services/services.module';
import { Module } from "@nestjs/common";
import { AnalysisController } from "./analysis.controller";
import { AnalysisService } from "./analysis.service";
import { DatabaseModule } from "../../database/database.module";
import { ServicesModule } from "../../services/services.module";
@Module({
imports: [DatabaseModule, ServicesModule],
+7 -7
View File
@@ -1,9 +1,9 @@
import { Injectable, Logger } from '@nestjs/common';
import { PrismaService } from '../../database/prisma.service';
import { Injectable, Logger } from "@nestjs/common";
import { PrismaService } from "../../database/prisma.service";
import {
MatchAnalysisService,
AnalysisResult,
} from '../../services/match-analysis.service';
} from "../../services/match-analysis.service";
@Injectable()
export class AnalysisService {
@@ -50,9 +50,9 @@ export class AnalysisService {
}
// Build URL for analysis
const sport = (targetMatch as any).sport || 'football';
const sport = (targetMatch as any).sport || "football";
const slug = (targetMatch as any).matchSlug || matchId;
const url = `https://www.mackolik.com/${sport === 'basketball' ? 'basketbol/mac' : 'mac'}/${slug}/${matchId}`;
const url = `https://www.mackolik.com/${sport === "basketball" ? "basketbol/mac" : "mac"}/${slug}/${matchId}`;
// Run analysis
const result = await this.matchAnalysisService.analyzeMatch(
@@ -110,7 +110,7 @@ export class AnalysisService {
// Check limits (default: 10 analyses, 3 coupons per day)
const user = await this.prisma.user.findUnique({ where: { id: userId } });
const isPremium = user?.subscriptionStatus === 'active';
const isPremium = user?.subscriptionStatus === "active";
const maxAnalyses = isPremium ? 50 : 10;
const maxCoupons = isPremium ? 10 : 3;
@@ -145,7 +145,7 @@ export class AnalysisService {
async getAnalysisHistory(userId: string, limit: number = 20) {
return this.prisma.analysis.findMany({
where: { userId },
orderBy: { createdAt: 'desc' },
orderBy: { createdAt: "desc" },
take: limit,
});
}
@@ -1,10 +1,10 @@
import { IsArray, IsString, ArrayMinSize, ArrayMaxSize } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsString, ArrayMinSize, ArrayMaxSize } from "class-validator";
import { ApiProperty } from "@nestjs/swagger";
export class AnalyzeMatchesDto {
@ApiProperty({
description: 'List of match IDs to analyze',
example: ['match-1', 'match-2'],
description: "List of match IDs to analyze",
example: ["match-1", "match-2"],
minItems: 1,
maxItems: 20,
})