This commit is contained in:
@@ -251,6 +251,10 @@ export class FeederPersistenceService {
|
||||
if (existingLeague) {
|
||||
// If exists with different ID, use existing ID to prevent constraint errors
|
||||
finalLeagueId = existingLeague.id;
|
||||
// Update sortOrder if changed
|
||||
if (league.sortOrder !== undefined) {
|
||||
await tx.$executeRaw`UPDATE leagues SET sort_order = ${league.sortOrder} WHERE id = ${finalLeagueId}`;
|
||||
}
|
||||
} else {
|
||||
// Create new league
|
||||
await tx.league.create({
|
||||
@@ -261,8 +265,11 @@ export class FeederPersistenceService {
|
||||
sport: sport,
|
||||
competitionSlug: league.competitionSlug,
|
||||
logoUrl: `/uploads/competitions/${finalLeagueId}.png`,
|
||||
},
|
||||
} as any,
|
||||
});
|
||||
if (league.sortOrder !== undefined) {
|
||||
await tx.$executeRaw`UPDATE leagues SET sort_order = ${league.sortOrder} WHERE id = ${finalLeagueId}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -323,6 +323,11 @@ export class FeederService {
|
||||
return;
|
||||
}
|
||||
|
||||
// Inject sortOrder from mackolik competition order (key position = display order)
|
||||
Object.keys(data.competitions).forEach((compId, idx) => {
|
||||
(data.competitions[compId] as Competition).sortOrder = idx;
|
||||
});
|
||||
|
||||
// Filter matches with iddaa code and deduplicate
|
||||
const rawMatches = Object.values(
|
||||
data.matches,
|
||||
|
||||
@@ -77,6 +77,7 @@ export interface Competition {
|
||||
id: string;
|
||||
name: string;
|
||||
competitionSlug: string;
|
||||
sortOrder?: number;
|
||||
country: {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
@@ -320,10 +320,11 @@ export class MatchesService {
|
||||
const leagueId = match.leagueId || "unknown";
|
||||
|
||||
if (!leaguesMap.has(leagueId)) {
|
||||
leaguesMap.set(leagueId, {
|
||||
const entry: any = {
|
||||
id: leagueId,
|
||||
name: match.league?.name || "Unknown League",
|
||||
code: match.league?.code || undefined,
|
||||
_league: match.league, // for sortOrder access
|
||||
country: {
|
||||
id: match.league?.country?.id || "",
|
||||
name: match.league?.country?.name || "",
|
||||
@@ -333,7 +334,8 @@ export class MatchesService {
|
||||
},
|
||||
sport: sport,
|
||||
matches: [],
|
||||
});
|
||||
};
|
||||
leaguesMap.set(leagueId, entry);
|
||||
}
|
||||
|
||||
const league = leaguesMap.get(leagueId)!;
|
||||
@@ -397,12 +399,21 @@ export class MatchesService {
|
||||
}
|
||||
|
||||
return Array.from(leaguesMap.values()).sort((a, b) => {
|
||||
const aIdx = this.topLeagueIds.indexOf(a.id);
|
||||
const bIdx = this.topLeagueIds.indexOf(b.id);
|
||||
const aPriority = aIdx === -1 ? 999 : aIdx;
|
||||
const bPriority = bIdx === -1 ? 999 : bIdx;
|
||||
// 1. top_leagues.json sırası (sabit öncelik listesi)
|
||||
const aTop = this.topLeagueIds.indexOf(a.id);
|
||||
const bTop = this.topLeagueIds.indexOf(b.id);
|
||||
const aTopPriority = aTop === -1 ? 999 : aTop;
|
||||
const bTopPriority = bTop === -1 ? 999 : bTop;
|
||||
if (aTopPriority !== bTopPriority) return aTopPriority - bTopPriority;
|
||||
|
||||
if (aPriority !== bPriority) return aPriority - bPriority;
|
||||
// 2. Mackolik'ten gelen sortOrder (feeder her gün güncelliyor)
|
||||
const leagueA = (a as any)._league as any;
|
||||
const leagueB = (b as any)._league as any;
|
||||
const aSortOrder = leagueA?.sortOrder ?? 9999;
|
||||
const bSortOrder = leagueB?.sortOrder ?? 9999;
|
||||
if (aSortOrder !== bSortOrder) return aSortOrder - bSortOrder;
|
||||
|
||||
// 3. Alfabetik fallback
|
||||
return (a.name || "").localeCompare(b.name || "");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1194,13 +1194,13 @@ export class PredictionsService implements OnModuleInit, OnModuleDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
// Direct HTTP mode
|
||||
// Direct HTTP mode — coupon needs longer timeout (many matches)
|
||||
try {
|
||||
const response = await this.aiEngineClient.post("/smart-coupon", {
|
||||
match_ids: matchIds,
|
||||
strategy,
|
||||
...options,
|
||||
});
|
||||
}, { timeout: 300000 }); // 5 dakika
|
||||
return response.data;
|
||||
} catch (error: unknown) {
|
||||
const message =
|
||||
|
||||
Reference in New Issue
Block a user