Skip to content

Commit 0b8ba2c

Browse files
committed
mirage/route-handlers/crates: Add support for sorting by recent-downloads
1 parent 2963928 commit 0b8ba2c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mirage/route-handlers/crates.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export function list(schema, request) {
4444

4545
if (request.queryParams.sort === 'alpha') {
4646
crates = crates.sort((a, b) => compareStrings(a.id.toLowerCase(), b.id.toLowerCase()));
47+
} else if (request.queryParams.sort === 'recent-downloads') {
48+
crates = crates.sort((a, b) => b.recent_downloads - a.recent_downloads);
4749
}
4850

4951
return { ...this.serialize(crates.slice(start, end)), meta: { total: crates.length } };

0 commit comments

Comments
 (0)