diff --git a/database-seeds/scripts/rerunners/add-usc-converts.js b/database-seeds/scripts/rerunners/add-usc-converts.js index c4c06938d..704b421b5 100644 --- a/database-seeds/scripts/rerunners/add-usc-converts.js +++ b/database-seeds/scripts/rerunners/add-usc-converts.js @@ -19,7 +19,7 @@ console.log(`Found ${dbRows.length} charts.`); const songs = ReadCollection("songs-usc.json"); const charts = ReadCollection("charts-usc.json"); -let maxSongId = Math.max(...songs.map(s => s.id)); +let maxSongId = Math.max(...songs.map((s) => s.id)); const folderIdToSongId = {}; let newSongs = 0; @@ -27,25 +27,29 @@ let newCharts = 0; for (const chart of dbRows) { // Check if chart already exists by comparing hash - const existingChart = charts.find(c => c.data.hashSHA1 === chart.hash); + const existingChart = charts.find((c) => c.data.hashSHA1 === chart.hash); if (existingChart) { - if (DEBUG) + if (DEBUG) { console.log(`Chart ${chart.title} ${existingChart.difficulty} already exists.`); + } continue; } if (!folderIdToSongId[chart.folderid]) { const splitPath = chart.path.replaceAll("\\", "/").split("/"); const folderName = splitPath[splitPath.length - 2]; - const existingSong = songs.find(s => - (s.title === chart.title - || s.searchTerms.includes(folderName) - || s.searchTerms.includes(folderName.replaceAll("_", " ")) - || s.searchTerms.includes(folderName.replaceAll(" ", "_"))) - && s.artist === chart.artist); + const existingSong = songs.find( + (s) => + (s.title === chart.title || + s.searchTerms.includes(folderName) || + s.searchTerms.includes(folderName.replaceAll("_", " ")) || + s.searchTerms.includes(folderName.replaceAll(" ", "_"))) && + s.artist === chart.artist + ); if (existingSong) { - if (DEBUG) + if (DEBUG) { console.log(`Song ${folderName} already exists with id ${existingSong.id}.`); + } folderIdToSongId[chart.folderid] = existingSong.id; } else { const songID = maxSongId + 1; @@ -60,8 +64,9 @@ for (const chart of dbRows) { }); folderIdToSongId[chart.folderid] = songID; newSongs++; - if (DEBUG) + if (DEBUG) { console.log(`Added song ${songID} for folder ${folderName}.`); + } } } @@ -90,8 +95,9 @@ for (const chart of dbRows) { newCharts++; - if (DEBUG) + if (DEBUG) { console.log(`Added chart ${chart.title} ${chart.diff_shortname}.`); + } } console.log(`Added ${newSongs} new songs and ${newCharts} new charts.`);