Skip to content

Commit 550b3d6

Browse files
Merge pull request #892 from natboehm/add-recent-downloads
Add recent downloads
2 parents f490316 + 8c58451 commit 550b3d6

File tree

26 files changed

+482
-41
lines changed

26 files changed

+482
-41
lines changed

app/controllers/category/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ export default Controller.extend(PaginationMixin, {
77
queryParams: ['page', 'per_page', 'sort'],
88
page: '1',
99
per_page: 10,
10-
sort: 'downloads',
10+
sort: 'recent-downloads',
1111

1212
totalItems: computed.readOnly('model.meta.total'),
1313

1414
categoryController: controller('category'),
1515
category: computed.alias('categoryController.model'),
1616

1717
currentSortBy: computed('sort', function() {
18-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
18+
if (this.get('sort') === 'downloads') {
19+
return 'All-Time Downloads';
20+
} else if (this.get('sort') === 'alpha') {
21+
return 'Alphabetical';
22+
} else {
23+
return 'Recent Downloads';
24+
}
1925
}),
2026
});

app/controllers/crates.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export default Controller.extend(PaginationMixin, {
1414
totalItems: computed.readOnly('model.meta.total'),
1515

1616
currentSortBy: computed('sort', function() {
17-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
17+
if (this.get('sort') === 'downloads') {
18+
return 'All-Time Downloads';
19+
} else if (this.get('sort') === 'recent-downloads') {
20+
return 'Recent Downloads';
21+
} else {
22+
return 'Alphabetical';
23+
}
1824
}),
1925
});

app/controllers/keyword/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ export default Controller.extend(PaginationMixin, {
77
queryParams: ['page', 'per_page', 'sort'],
88
page: '1',
99
per_page: 10,
10-
sort: 'alpha',
10+
sort: 'recent-downloads',
1111

1212
totalItems: computed.readOnly('model.meta.total'),
1313

1414
currentSortBy: computed('sort', function() {
15-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
15+
if (this.get('sort') === 'downloads') {
16+
return 'All-Time Downloads';
17+
} else if (this.get('sort') === 'alpha') {
18+
return 'Alphabetical';
19+
} else {
20+
return 'Recent Downloads';
21+
}
1622
}),
1723
});

app/controllers/search.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ export default Controller.extend(PaginationMixin, {
1313
totalItems: computed.readOnly('model.meta.total'),
1414

1515
currentSortBy: computed('sort', function() {
16-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Relevance';
16+
if (this.get('sort') === 'downloads') {
17+
return 'All-Time Downloads';
18+
} else if (this.get('sort') === 'recent-downloads') {
19+
return 'Recent Downloads';
20+
} else {
21+
return 'Relevance';
22+
}
1723
}),
1824

1925
hasItems: computed.bool('totalItems'),

app/controllers/team.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export default Controller.extend(PaginationMixin, {
1212
totalItems: computed.readOnly('model.crates.meta.total'),
1313

1414
currentSortBy: computed('sort', function() {
15-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
15+
if (this.get('sort') === 'downloads') {
16+
return 'All-Time Downloads';
17+
} else if (this.get('sort') === 'recent-downloads') {
18+
return 'Recent Downloads';
19+
} else {
20+
return 'Alphabetical';
21+
}
1622
}),
1723
});

app/controllers/user.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export default Controller.extend(PaginationMixin, {
1313
totalItems: computed.readOnly('model.crates.meta.total'),
1414

1515
currentSortBy: computed('sort', function() {
16-
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
16+
if (this.get('sort') === 'downloads') {
17+
return 'All-Time Downloads';
18+
} else if (this.get('sort') === 'recent-downloads') {
19+
return 'Recent Downloads';
20+
} else {
21+
return 'Alphabetical';
22+
}
1723
}),
1824
});

app/models/crate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DS from 'ember-data';
44
export default DS.Model.extend({
55
name: DS.attr('string'),
66
downloads: DS.attr('number'),
7+
recent_downloads: DS.attr('number'),
78
created_at: DS.attr('date'),
89
updated_at: DS.attr('date'),
910
max_version: DS.attr('string'),

app/routes/team.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import RSVP from 'rsvp';
2-
import { inject as service } from '@ember/service';
31
import Route from '@ember/routing/route';
2+
import { inject as service } from '@ember/service';
3+
import RSVP from 'rsvp';
44

55
export default Route.extend({
66
flashMessages: service(),
77

88
queryParams: {
9-
page: { refreshedModel: true },
10-
sort: { refreshedModel: true },
9+
page: { refreshModel: true },
10+
sort: { refreshModel: true },
1111
},
1212
data: {},
1313

app/styles/crate.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
padding-top: 5px;
120120
@include display-flex;
121121
@include flex-direction(column);
122-
width: 85%;
122+
width: 75%;
123123
}
124124

125125
.info a {
@@ -133,10 +133,18 @@
133133
}
134134

135135
.stats {
136-
width: 15%;
136+
width: 25%;
137137
color: $main-color-light;
138138
}
139-
.downloads { @include display-flex; @include align-items(center); }
139+
.downloads {
140+
@include display-flex;
141+
@include align-items(center);
142+
padding-bottom: 5px;
143+
}
144+
.recent-downloads {
145+
@include display-flex;
146+
@include align-items(center);
147+
}
140148

141149
.rev-dep-downloads {padding-left: 7px}
142150
}

app/templates/category/index.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@
6161
</li>
6262
<li>
6363
{{#link-to (query-params sort="downloads")}}
64-
Downloads
64+
All-Time Downloads
65+
{{/link-to}}
66+
</li>
67+
<li>
68+
{{#link-to (query-params sort="recent-downloads")}}
69+
Recent Downloads
6570
{{/link-to}}
6671
</li>
6772
{{/rl-dropdown}}

app/templates/components/crate-row.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
<div class='stats'>
2121
<div class='downloads'>
2222
{{svg-jar "download"}}
23-
<span class='num'>{{ format-num crate.downloads }}</span>
23+
<span class='num'>All-Time: {{ format-num crate.downloads }}</span>
24+
</div>
25+
<div class="recent-downloads">
26+
{{svg-jar "download"}}
27+
<span class='num'>Recent: {{ format-num crate.recent_downloads }}</span>
2428
</div>
2529
</div>
2630
<div class="quick-links">

app/templates/crates.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
</li>
5353
<li>
5454
{{#link-to (query-params page=1 sort="downloads")}}
55-
Downloads
55+
All-Time Downloads
56+
{{/link-to}}
57+
</li>
58+
<li>
59+
{{#link-to (query-params page=1 sort="recent-downloads")}}
60+
Recent Downloads
5661
{{/link-to}}
5762
</li>
5863
{{/rl-dropdown}}

app/templates/keyword/index.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@
3232
</li>
3333
<li>
3434
{{#link-to (query-params sort="downloads")}}
35-
Downloads
35+
All-Time Downloads
36+
{{/link-to}}
37+
</li>
38+
<li>
39+
{{#link-to (query-params sort="recent-downloads")}}
40+
Recent Downloads
3641
{{/link-to}}
3742
</li>
3843
{{/rl-dropdown}}

app/templates/search.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
</li>
3939
<li>
4040
{{#link-to (query-params page=1 sort="downloads")}}
41-
Downloads
41+
All-Time Downloads
42+
{{/link-to}}
43+
</li>
44+
<li>
45+
{{#link-to (query-params page=1 sort="recent-downloads")}}
46+
Recent Downloads
4247
{{/link-to}}
4348
</li>
4449
{{/rl-dropdown}}

app/templates/team.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@
4747
</li>
4848
<li>
4949
{{#link-to (query-params sort="downloads")}}
50-
Downloads
50+
All-Time Downloads
51+
{{/link-to}}
52+
</li>
53+
<li>
54+
{{#link-to (query-params sort="recent-downloads")}}
55+
Recent Downloads
5156
{{/link-to}}
5257
</li>
5358
{{/rl-dropdown}}

app/templates/user.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
</li>
3939
<li>
4040
{{#link-to (query-params sort="downloads")}}
41-
Downloads
41+
All-Time Downloads
42+
{{/link-to}}
43+
</li>
44+
<li>
45+
{{#link-to (query-params sort="recent-downloads")}}
46+
Recent Downloads
4247
{{/link-to}}
4348
</li>
4449
{{/rl-dropdown}}

mirage/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ export default function() {
170170
return withMeta(this.serialize(categories), { total });
171171
});
172172

173+
this.get('/categories/:category_id', function(schema, request) {
174+
let catId = request.params.category_id;
175+
let category = schema.categories.find(catId);
176+
return category ? category : notFound();
177+
});
178+
173179
this.get('/keywords', function(schema, request) {
174180
let { start, end } = pageParams(request);
175181

0 commit comments

Comments
 (0)