diff --git a/server/src/scripts/import.ts b/server/src/scripts/import.ts index 45410ee..6b8d8a1 100644 --- a/server/src/scripts/import.ts +++ b/server/src/scripts/import.ts @@ -68,6 +68,7 @@ const GENRE_SEARCH_TAGS: Record = { }; const QUOTA_PER_GENRE = parseInt(process.argv[3], 10) || 10; +const MIN_RELEASES = parseInt(process.argv[4], 10) || 3; async function mbFetch(url: string): Promise { for (let attempt = 1; attempt <= 4; attempt++) { @@ -168,14 +169,16 @@ async function importAlbum( async function importDecade(startYear: number) { const endYear = startYear + 9; - console.log(`\n=== Import for ${startYear}-${endYear} (kvote ${QUOTA_PER_GENRE}/sjanger) ===`); - + console.log(`\n=== Import for ${startYear}-${endYear} (kvote ${QUOTA_PER_GENRE}/sjanger, min ${MIN_RELEASES} utgaver) ===`); + for (const [genreName, tag] of Object.entries(GENRE_SEARCH_TAGS)) { console.log(`\n--- ${genreName} (${startYear}-${endYear}) ---`); const query = `primarytype:album AND NOT secondarytype:* AND tag:"${tag}" ` + - `AND firstreleasedate:[${startYear} TO ${endYear}]`; + `AND firstreleasedate:[${startYear} TO ${endYear}]` + + `AND releases:[${MIN_RELEASES} TO *]`; + let imported = 0; let offset = 0; @@ -245,4 +248,7 @@ async function main() { console.log(`\nImport for ${targetYear}-tallet er fullført!`); } -main(); +main().catch((err) => { + console.error('Fatal feil:', err); + process.exit(1); +});