File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -55,18 +55,11 @@ export async function POST(req: NextRequest) {
55
55
const results = await response . json ( ) ;
56
56
57
57
const searchResults = results . results
58
- . sort ( ( a : any , b : any ) => {
59
- const scoreDifference = b . score - a . score ;
60
- if ( scoreDifference !== 0 ) return scoreDifference ;
61
-
62
- if ( time_range ) {
63
- const dateA = new Date ( a . publishedDate || 0 ) . getTime ( ) ;
64
- const dateB = new Date ( b . publishedDate || 0 ) . getTime ( ) ;
65
- return dateB - dateA ;
66
- }
67
-
68
- return 0 ;
69
- } )
58
+ . sort ( ( a : any , b : any ) =>
59
+ b . score !== a . score
60
+ ? b . score - a . score
61
+ : new Date ( b . publishedDate || 0 ) . getTime ( ) - new Date ( a . publishedDate || 0 ) . getTime ( )
62
+ )
70
63
. slice ( 0 , max_results ) ;
71
64
console . log ( 'Search Results:' , searchResults ) ;
72
65
You can’t perform that action at this time.
0 commit comments