Skip to content

Commit 21bedda

Browse files
Merge #1121
1121: [#962] Add "Most Recent Downloads" category r=carols10cents
2 parents dd2d17e + f1ee1f8 commit 21bedda

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

app/routes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default Route.extend({
2424
addCrates(this.store, data.new_crates);
2525
addCrates(this.store, data.most_downloaded);
2626
addCrates(this.store, data.just_updated);
27+
addCrates(this.store, data.most_recently_downloaded);
2728

2829
return data;
2930
});

app/templates/index.hbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<h2>Just Updated</h2>
4949
{{crate-list crates=model.just_updated}}
5050
</div>
51+
<div id='most-recently-downloaded'>
52+
<h2>Most Recent Downloads</h2>
53+
{{crate-list crates=model.most_recently_downloaded}}
54+
</div>
5155
<div id='keywords'>
5256
<h2>Popular Keywords {{#link-to 'keywords'}}(see all){{/link-to}}</h2>
5357
{{keyword-list keywords=model.popular_keywords}}

mirage/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default function() {
99
let just_updated = crates.sort((a, b) => compareIsoDates(b.updated_at, a.updated_at)).slice(0, 10);
1010
let most_downloaded = crates.sort((a, b) => b.downloads - a.downloads).slice(0, 10);
1111
let new_crates = crates.sort((a, b) => compareIsoDates(b.created_at, a.created_at)).slice(0, 10);
12+
let most_recently_downloaded = crates.sort((a, b) => b.recent_downloads - a.recent_downloads).slice(0, 10);
1213

1314
let num_crates = crates.length;
1415
let num_downloads = crates.models.reduce((sum, crate) => sum + crate.downloads, 0);
@@ -23,6 +24,8 @@ export default function() {
2324
.map(it => ({ ...it, versions: null })),
2425
new_crates: this.serialize(new_crates).crates
2526
.map(it => ({ ...it, versions: null })),
27+
most_recently_downloaded: this.serialize(most_recently_downloaded).crates
28+
.map(it => ({ ...it, versions: null })),
2629
num_crates,
2730
num_downloads,
2831
popular_categories: this.serialize(popular_categories).categories,

0 commit comments

Comments
 (0)