mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
replace sorting into filtering approach
This commit is contained in:
parent
b9ec201c84
commit
1a62185c17
1 changed files with 6 additions and 11 deletions
|
@ -24,17 +24,12 @@ export async function searchForMedia(query: MWQuery): Promise<MediaItem[]> {
|
|||
return formatTMDBMetaToMediaItem(formattedResult);
|
||||
});
|
||||
|
||||
results.sort((a, b) => {
|
||||
if (a.poster === undefined) {
|
||||
return 1;
|
||||
}
|
||||
if (b.poster === undefined) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
const movieWithposters = results.filter((movie) => movie.poster);
|
||||
const movieWithoutposters = results.filter((movie) => !movie.poster);
|
||||
|
||||
const sortedresult = movieWithposters.concat(movieWithoutposters);
|
||||
|
||||
// cache results for 1 hour
|
||||
cache.set(query, results, 3600);
|
||||
return results;
|
||||
cache.set(query, sortedresult, 3600);
|
||||
return sortedresult;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue