fix/dev: fix devscripts for platform

This commit is contained in:
2026-04-18 14:43:56 +02:00
parent 2c774caf5f
commit 17024f91a8

View File

@@ -42,7 +42,7 @@ async function setupDatabase() {
// Check for platform-specific match files
let foundPlatformFiles = [];
for (const platform of platforms) {
const platformFile = `${latestPatch}_${platform}_matches.json`;
const platformFile = `${latestPatch}_${platform}.json`;
const fullPath = path.join(dataDir, platformFile);
if (fs.existsSync(fullPath)) {
foundPlatformFiles.push(platform);
@@ -323,9 +323,15 @@ async function importMatchesData(patchVersion, foundPlatformFiles = []) {
// If platform-specific files were found, import each one
if (foundPlatformFiles.length > 0) {
for (const platform of foundPlatformFiles) {
const matchesFile = path.join(dataDir, `${patchVersion}_${platform}_matches.json`);
// Try both formats: patch_PLATFORM.json and patch_PLATFORM_matches.json
let matchesFile = path.join(dataDir, `${patchVersion}_${platform}.json`);
const collectionName = `${patchVersion}_${platform}`;
// Fallback to _matches.json suffix if the direct file doesn't exist
if (!fs.existsSync(matchesFile)) {
matchesFile = path.join(dataDir, `${patchVersion}_${platform}_matches.json`);
}
if (fs.existsSync(matchesFile)) {
console.log(`📥 Importing matches for ${platform}...`);
execSync(
@@ -336,13 +342,21 @@ async function importMatchesData(patchVersion, foundPlatformFiles = []) {
}
);
console.log(`✅ Matches import completed for ${platform}`);
} else {
console.log(`⚠️ No match file found for ${platform}`);
}
}
} else {
// Fall back to old format (single file without platform suffix)
const matchesFile = path.join(dataDir, `${patchVersion}_matches.json`);
// Try both formats: patch_matches.json and patch.json
let matchesFile = path.join(dataDir, `${patchVersion}_matches.json`);
const collectionName = patchVersion;
if (!fs.existsSync(matchesFile)) {
matchesFile = path.join(dataDir, `${patchVersion}.json`);
}
if (fs.existsSync(matchesFile)) {
execSync(
`node ${path.join(__dirname, 'process-matches.js')} ${matchesFile} ${collectionName} 1000`,
{
@@ -351,6 +365,9 @@ async function importMatchesData(patchVersion, foundPlatformFiles = []) {
}
);
console.log('✅ Matches import completed');
} else {
console.log(`⚠️ No match file found for patch ${patchVersion}`);
}
}
} catch (error) {
console.error('❌ Failed to import matches:', error);