Skip to content

Commit ca245db

Browse files
committed
sorting algorithm adjustments
1 parent 4950199 commit ca245db

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/queries/combined-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class SearchResults {
4545
}
4646
stitched_tokens = stitched_tokens + token;
4747
}
48-
48+
4949
const fuse_results = fuse.search(stitched_tokens);
5050

5151
// Assign weight based on relevance
@@ -55,7 +55,8 @@ export class SearchResults {
5555

5656
// Sort by download count
5757
this.results.sort((a, b) => {
58-
return (b.weight + Math.pow((b.downloads / a.downloads), this.download_weight)) - (a.weight + Math.pow((a.downloads / b.downloads), this.download_weight));
58+
return (b.weight + ((b.weight > 1.5) ? (Math.pow((b.downloads / a.downloads), this.download_weight)) : (Math.pow((b.downloads / a.downloads), this.download_weight/4))))
59+
- (a.weight + ((b.weight > 1.5) ? (Math.pow((a.downloads / b.downloads), this.download_weight)) : (Math.pow((a.downloads / b.downloads), this.download_weight/4))));
5960
});
6061
}
6162
// Otherwise sort only by download count

0 commit comments

Comments
 (0)