1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-30 16:17:41 +01:00

replace sorting into filtering approach

This commit is contained in:
Ashishprasa 2024-01-01 22:59:33 +05:30
parent b9ec201c84
commit 1a62185c17

View file

@ -24,17 +24,12 @@ export async function searchForMedia(query: MWQuery): Promise<MediaItem[]> {
return formatTMDBMetaToMediaItem(formattedResult); return formatTMDBMetaToMediaItem(formattedResult);
}); });
results.sort((a, b) => { const movieWithposters = results.filter((movie) => movie.poster);
if (a.poster === undefined) { const movieWithoutposters = results.filter((movie) => !movie.poster);
return 1;
} const sortedresult = movieWithposters.concat(movieWithoutposters);
if (b.poster === undefined) {
return -1;
}
return 0;
});
// cache results for 1 hour // cache results for 1 hour
cache.set(query, results, 3600); cache.set(query, sortedresult, 3600);
return results; return sortedresult;
} }