hopefully improve id fetching

This commit is contained in:
Jill 2024-02-23 01:02:30 +03:00
parent 527aa16045
commit 704581d013
Signed by: oat
GPG Key ID: 33489AA58A955108
2 changed files with 8 additions and 3 deletions

View File

@ -83,10 +83,10 @@ async function fetchLevelData(name, creator, loose = false) {
const exact = data.hits.filter(h => h.cache_level_name.toLowerCase() === name.toLowerCase());
if (exact.length === 1) return exact[0];
const creatorHits = data.hits.filter(h => creator.toLowerCase().includes(h.cache_username.toLowerCase()));
const creatorHits = data.hits.filter(h => creator.toLowerCase().includes(h.cache_username.toLowerCase()) || h.cache_username.toLowerCase().includes(creator.toLowerCase()));
if (creatorHits.length === 1) return creatorHits[0];
return data.hits[0];
return data.hits.sort((a, b) => b.cache_demon_type - a.cache_demon_type)[0]; // pick highest demon diff. somehow effective? very stupid
}
const metadataFetchQueue = new PQueue({ concurrency: 10, interval: 500, intervalCap: 2 });

7
nlw.js
View File

@ -19,8 +19,13 @@ const fruityLevels = {
'gardening map': 'gardening map ',
'Flying Maze': 'Floating Outskirts',
'dickglark 3': 'nevermore',
'SHATTER': 'SHATTER ',
};
const fruityCreators = {
'Kapycta9⃣9⃣9⃣': 'Kapycta999', // woo unicode
}
const brokenColors = {
'0,0,0': 'no',
'67,67,67': 'slightly',
@ -136,7 +141,7 @@ async function fetchLevels(sheet, platformer, pending) {
sheetIndex: parseInt(i),
tier: lastTier,
name: fruityLevels[level[0]] || level[0] || "",
creator: (creator && creator[0] || "").trim(),
creator: creator ? (fruityCreators[creator[0]] || creator[0] || "") : "",
skillset: (skillset && skillset[0] || "").trim(),
enjoyment: !isNaN(enjoymentParse) ? enjoymentParse : null,
description: (description && description[0] || "").trim(),