Skip to content

Add recent downloads #892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc182a5
query for recent_downloads
natboehm Jul 10, 2017
36fe81c
correctly displays top recently downloaded crates
natboehm Jul 10, 2017
5017507
Added recent_downloads to encodable_crate
natboehm Jul 10, 2017
776ed77
addition of dropdown selection for ability to sort by recent downloads
natboehm Jul 10, 2017
642a095
all-time and in past 90 days downloads displayed in list, currently b…
natboehm Jul 11, 2017
c105307
increased size of stats div
natboehm Jul 11, 2017
1f9c68a
Remove unused code for showing only either recent downloads or all ti…
natboehm Jul 12, 2017
13491f1
Misplaced paren, fixes weird searching bug
natboehm Jul 12, 2017
3ba4e41
Add recent download sort to user page
natboehm Jul 12, 2017
62a2110
Added sort by recent downloads to team page
natboehm Jul 12, 2017
908ad06
Fixes bug on team page where dropdown selection was not changing sort…
natboehm Jul 12, 2017
420b97a
fix broken test for list of crates returned by search
natboehm Jul 13, 2017
2d87b06
null error when trying to get count
natboehm Jul 14, 2017
6036807
Fixes error in tests where crates with zero downloads could not be gr…
natboehm Jul 14, 2017
121fdbf
tests for adding crates when sort = recent-downloads
natboehm Jul 17, 2017
7d66ac0
Change default sort from alpha to recent-downloads overall, alpha to …
natboehm Jul 18, 2017
8946d2a
Add test for checking that the keyword index page and category index …
natboehm Jul 18, 2017
549683f
Add test to check that when searching exact match is first and the li…
natboehm Jul 18, 2017
15975d1
delete debug statement, clean up join function
natboehm Jul 18, 2017
6609e04
add comments for tests written
natboehm Jul 18, 2017
0fb2e18
Add recent download option to category index page, change default sor…
natboehm Jul 18, 2017
e11724a
Add recent download option to keyword index page, change default sort…
natboehm Jul 18, 2017
34a30d5
add recent_downloads to fixture data
natboehm Jul 18, 2017
d3f1e16
fix double quote linting error
natboehm Jul 18, 2017
b1a9aa5
frontend tests for displaying and sorting by recent downloads
natboehm Jul 18, 2017
625f04c
change 'All Time' to 'All-Time' for consistency
natboehm Jul 18, 2017
9970d6d
remove unused variable
natboehm Jul 18, 2017
e9cdc76
cargo fmt
natboehm Jul 19, 2017
b086a6d
fixes bug where null downloads would be listed first when sorting by …
natboehm Jul 25, 2017
d5455cc
put back deny warnings
natboehm Jul 25, 2017
fb719cc
Add Debug to CrateDownload struct
natboehm Jul 25, 2017
b13c432
add recent_downloads to crate serializer, update test to match
natboehm Jul 25, 2017
1c3f3c6
delete duplicate code & whitespace
natboehm Jul 25, 2017
20f42d9
allow too many arguments on krate::encodable
natboehm Jul 25, 2017
1acfbef
cargo fmt
natboehm Jul 25, 2017
dfb21b8
really allow too many arguments on krate::encodable
natboehm Jul 25, 2017
8c58451
actually allow too many arguments on krate::encodable (change feature…
natboehm Jul 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions app/controllers/category/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ export default Controller.extend(PaginationMixin, {
queryParams: ['page', 'per_page', 'sort'],
page: '1',
per_page: 10,
sort: 'downloads',
sort: 'recent-downloads',

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

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

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'alpha') {
return 'Alphabetical';
} else {
return 'Recent Downloads';
}
}),
});
8 changes: 7 additions & 1 deletion app/controllers/crates.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export default Controller.extend(PaginationMixin, {
totalItems: computed.readOnly('model.meta.total'),

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'recent-downloads') {
return 'Recent Downloads';
} else {
return 'Alphabetical';
}
}),
});
10 changes: 8 additions & 2 deletions app/controllers/keyword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ export default Controller.extend(PaginationMixin, {
queryParams: ['page', 'per_page', 'sort'],
page: '1',
per_page: 10,
sort: 'alpha',
sort: 'recent-downloads',

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

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'alpha') {
return 'Alphabetical';
} else {
return 'Recent Downloads';
}
}),
});
8 changes: 7 additions & 1 deletion app/controllers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ export default Controller.extend(PaginationMixin, {
totalItems: computed.readOnly('model.meta.total'),

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Relevance';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'recent-downloads') {
return 'Recent Downloads';
} else {
return 'Relevance';
}
}),

hasItems: computed.bool('totalItems'),
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export default Controller.extend(PaginationMixin, {
totalItems: computed.readOnly('model.crates.meta.total'),

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'recent-downloads') {
return 'Recent Downloads';
} else {
return 'Alphabetical';
}
}),
});
8 changes: 7 additions & 1 deletion app/controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export default Controller.extend(PaginationMixin, {
totalItems: computed.readOnly('model.crates.meta.total'),

currentSortBy: computed('sort', function() {
return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'recent-downloads') {
return 'Recent Downloads';
} else {
return 'Alphabetical';
}
}),
});
1 change: 1 addition & 0 deletions app/models/crate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
downloads: DS.attr('number'),
recent_downloads: DS.attr('number'),
created_at: DS.attr('date'),
updated_at: DS.attr('date'),
max_version: DS.attr('string'),
Expand Down
8 changes: 4 additions & 4 deletions app/routes/team.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import RSVP from 'rsvp';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import RSVP from 'rsvp';

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

queryParams: {
page: { refreshedModel: true },
sort: { refreshedModel: true },
page: { refreshModel: true },
sort: { refreshModel: true },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how you figured out this was needed; I don't think I could have!!! I'm super impressed!!! 😻

},
data: {},

Expand Down
14 changes: 11 additions & 3 deletions app/styles/crate.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
padding-top: 5px;
@include display-flex;
@include flex-direction(column);
width: 85%;
width: 75%;
}

.info a {
Expand All @@ -133,10 +133,18 @@
}

.stats {
width: 15%;
width: 25%;
color: $main-color-light;
}
.downloads { @include display-flex; @include align-items(center); }
.downloads {
@include display-flex;
@include align-items(center);
padding-bottom: 5px;
}
.recent-downloads {
@include display-flex;
@include align-items(center);
}

.rev-dep-downloads {padding-left: 7px}
}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/category/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@
</li>
<li>
{{#link-to (query-params sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
6 changes: 5 additions & 1 deletion app/templates/components/crate-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
<div class='stats'>
<div class='downloads'>
{{svg-jar "download"}}
<span class='num'>{{ format-num crate.downloads }}</span>
<span class='num'>All-Time: {{ format-num crate.downloads }}</span>
</div>
<div class="recent-downloads">
{{svg-jar "download"}}
<span class='num'>Recent: {{ format-num crate.recent_downloads }}</span>
</div>
</div>
<div class="quick-links">
Expand Down
7 changes: 6 additions & 1 deletion app/templates/crates.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
</li>
<li>
{{#link-to (query-params page=1 sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params page=1 sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/keyword/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
</li>
<li>
{{#link-to (query-params sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
</li>
<li>
{{#link-to (query-params page=1 sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params page=1 sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/team.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@
</li>
<li>
{{#link-to (query-params sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
7 changes: 6 additions & 1 deletion app/templates/user.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
</li>
<li>
{{#link-to (query-params sort="downloads")}}
Downloads
All-Time Downloads
{{/link-to}}
</li>
<li>
{{#link-to (query-params sort="recent-downloads")}}
Recent Downloads
{{/link-to}}
</li>
{{/rl-dropdown}}
Expand Down
6 changes: 6 additions & 0 deletions mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ export default function() {
return withMeta(this.serialize(categories), { total });
});

this.get('/categories/:category_id', function(schema, request) {
let catId = request.params.category_id;
let category = schema.categories.find(catId);
return category ? category : notFound();
});

this.get('/keywords', function(schema, request) {
let { start, end } = pageParams(request);

Expand Down
Loading