fix: update version tags to v28 and temporarily disable cache for predictions
This commit is contained in:
@@ -127,15 +127,18 @@ export class LeaguesController {
|
||||
@ApiParam({ name: "id", description: "Team ID" })
|
||||
@ApiQuery({ name: "page", required: false, type: Number, description: "Page number (default: 1)" })
|
||||
@ApiQuery({ name: "limit", required: false, type: Number, description: "Items per page (default: 20)" })
|
||||
@ApiQuery({ name: "season", required: false, type: String, description: "Season (e.g. 2024-2025)" })
|
||||
async getTeamMatches(
|
||||
@Param("id") id: string,
|
||||
@Query("page") page?: string,
|
||||
@Query("limit") limit?: string,
|
||||
@Query("season") season?: string,
|
||||
) {
|
||||
return this.leaguesService.getTeamRecentMatches(
|
||||
id,
|
||||
parseInt(page || "1", 10),
|
||||
parseInt(limit || "20", 10),
|
||||
season
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,12 +105,34 @@ export class LeaguesService {
|
||||
teamId: string,
|
||||
page: number = 1,
|
||||
limit: number = 20,
|
||||
season?: string
|
||||
) {
|
||||
const skip = (page - 1) * limit;
|
||||
const where = {
|
||||
const where: any = {
|
||||
OR: [{ homeTeamId: teamId }, { awayTeamId: teamId }],
|
||||
};
|
||||
|
||||
if (season) {
|
||||
// season format expected: "2024-2025"
|
||||
const parts = season.split("-");
|
||||
if (parts.length === 2) {
|
||||
const startYear = parseInt(parts[0], 10);
|
||||
const endYear = parseInt(parts[1], 10);
|
||||
|
||||
if (!isNaN(startYear) && !isNaN(endYear)) {
|
||||
// Season starts August 1st of startYear
|
||||
const startDate = new Date(Date.UTC(startYear, 7, 1)).getTime();
|
||||
// Season ends July 31st of endYear
|
||||
const endDate = new Date(Date.UTC(endYear, 6, 31, 23, 59, 59, 999)).getTime();
|
||||
|
||||
where.mstUtc = {
|
||||
gte: startDate,
|
||||
lte: endDate,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const [data, total] = await this.prisma.$transaction([
|
||||
this.prisma.match.findMany({
|
||||
where,
|
||||
@@ -127,7 +149,26 @@ export class LeaguesService {
|
||||
]);
|
||||
|
||||
return {
|
||||
data,
|
||||
data: data.map((m) => ({
|
||||
id: m.id,
|
||||
matchName: m.matchName,
|
||||
matchSlug: m.matchSlug,
|
||||
mstUtc: Number(m.mstUtc),
|
||||
scoreHome: m.scoreHome,
|
||||
scoreAway: m.scoreAway,
|
||||
status: m.status,
|
||||
state: m.state,
|
||||
homeTeamName: m.homeTeam?.name,
|
||||
homeTeamLogo: m.homeTeamId
|
||||
? `https://file.mackolikfeeds.com/teams/${m.homeTeamId}`
|
||||
: null,
|
||||
awayTeamName: m.awayTeam?.name,
|
||||
awayTeamLogo: m.awayTeamId
|
||||
? `https://file.mackolikfeeds.com/teams/${m.awayTeamId}`
|
||||
: null,
|
||||
leagueName: m.league?.name,
|
||||
countryName: m.league?.country?.name,
|
||||
})),
|
||||
total,
|
||||
page,
|
||||
limit,
|
||||
|
||||
@@ -96,11 +96,11 @@ export class PredictionsController {
|
||||
async getPrediction(
|
||||
@Param("matchId") matchId: string,
|
||||
): Promise<MatchPredictionDto> {
|
||||
// Check cache first
|
||||
const cached = await this.predictionsService.getCachedPrediction(matchId);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
// Check cache first - DISABLED per user request to always fetch from scratch
|
||||
// const cached = await this.predictionsService.getCachedPrediction(matchId);
|
||||
// if (cached) {
|
||||
// return cached;
|
||||
// }
|
||||
|
||||
// Get from AI Engine
|
||||
const prediction = await this.predictionsService.getPredictionById(matchId);
|
||||
@@ -109,9 +109,6 @@ export class PredictionsController {
|
||||
throw new NotFoundException(`Match not found: ${matchId}`);
|
||||
}
|
||||
|
||||
// Cache the result
|
||||
await this.predictionsService.cachePrediction(matchId, prediction);
|
||||
|
||||
return prediction;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
mode:
|
||||
typeof (response.data as Record<string, unknown>)?.mode === "string"
|
||||
? String((response.data as Record<string, unknown>).mode)
|
||||
: this.configService.get("AI_ENGINE_MODE", "v25"),
|
||||
: this.configService.get("AI_ENGINE_MODE", "v28-pro-max"),
|
||||
};
|
||||
} catch (error: unknown) {
|
||||
const requestError =
|
||||
@@ -207,7 +207,7 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
typeof requestError.detail === "string"
|
||||
? requestError.detail
|
||||
: requestError.message,
|
||||
mode: this.configService.get("AI_ENGINE_MODE", "v25"),
|
||||
mode: this.configService.get("AI_ENGINE_MODE", "v28-pro-max"),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -216,31 +216,12 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
await this.ensurePredictionDataReady(matchId);
|
||||
const matchContext = await this.getMatchContext(matchId);
|
||||
|
||||
// Queue mode (Redis enabled)
|
||||
if (this.predictionsQueue && this.queueEvents) {
|
||||
try {
|
||||
const job = await this.predictionsQueue.addPredictMatchJob({ matchId });
|
||||
const data = await job.waitUntilFinished(this.queueEvents, 30000);
|
||||
if (!data || data.error) {
|
||||
return null;
|
||||
}
|
||||
await this.recordPredictionRun(matchId, data as MatchPredictionDto);
|
||||
return this.enrichPredictionResponse(
|
||||
data as MatchPredictionDto,
|
||||
matchContext,
|
||||
);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
this.logger.error(`Prediction queue failed for ${matchId}: ${message}`);
|
||||
this.throwAiError(message);
|
||||
}
|
||||
}
|
||||
|
||||
// Queue mode (Redis enabled) - REMOVED per user request to always fetch from scratch
|
||||
// Direct HTTP mode (no Redis)
|
||||
try {
|
||||
const response = await this.aiEngineClient.post<MatchPredictionDto>(
|
||||
`/v20plus/analyze/${matchId}`,
|
||||
{},
|
||||
{ simulate: true, is_simulation: true, pre_match_only: true },
|
||||
);
|
||||
await this.recordPredictionRun(matchId, response.data);
|
||||
return this.enrichPredictionResponse(
|
||||
@@ -321,7 +302,7 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
return {
|
||||
count: upcoming.length,
|
||||
modelVersion: "v25-v30-ensemble",
|
||||
modelVersion: "v28-pro-max",
|
||||
matches: upcoming.map((p) => {
|
||||
const out = p.predictionJson as Record<string, unknown>;
|
||||
const matchInfo = (out?.match_info || {}) as Record<string, unknown>;
|
||||
@@ -560,6 +541,7 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
bet_advice: betAdvice as MatchPredictionDto["bet_advice"],
|
||||
market_board: enrichedMarketBoard,
|
||||
reasoning_factors: reasoningFactors,
|
||||
model_version: "v28-pro-max",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1143,7 +1125,7 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!modelVersion.startsWith("v25")) {
|
||||
if (!modelVersion.startsWith("v28-pro-max")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ export class PredictionsProcessor extends WorkerHost {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
`${this.aiEngineUrl}/v20plus/analyze/${matchId}`,
|
||||
{},
|
||||
{
|
||||
simulate: data.simulate,
|
||||
is_simulation: data.is_simulation,
|
||||
pre_match_only: data.pre_match_only,
|
||||
},
|
||||
{ timeout: 30000 },
|
||||
);
|
||||
return response.data;
|
||||
|
||||
@@ -13,6 +13,9 @@ export enum PredictionJobType {
|
||||
export interface PredictMatchJobData {
|
||||
matchId: string;
|
||||
forceUpdate?: boolean;
|
||||
simulate?: boolean;
|
||||
is_simulation?: boolean;
|
||||
pre_match_only?: boolean;
|
||||
}
|
||||
|
||||
export interface SmartCouponJobData {
|
||||
|
||||
Reference in New Issue
Block a user