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

Conversation

natboehm
Copy link
Contributor

@natboehm natboehm commented Jul 18, 2017

This addresses issue #702, sorting crates by downloads in the past 90 days. The implementation follows Option 2 detailed in the issue, adding a new option to all sorting menus for downloads in the last 90 days and keeping the option to sort by all-time downloads. The number of recent downloads has been added to display below all-time downloads next to each crate, labeled accordingly.

This PR is currently waiting on updates to Diesel, without which it will not function correctly.
( edit: updates to Diesel complete :) )

Fixes #702

@vignesh-sankaran
Copy link
Contributor

vignesh-sankaran commented Jul 19, 2017

@natboehm: Could you run a cargo fmt against the codebase and push the formatted code up please? :)

@natboehm
Copy link
Contributor Author

@vignesh-sankaran forgot about that one, will do!

@vignesh-sankaran
Copy link
Contributor

@natboehm Thanks for that :). Which version of Diesel were you waiting on in order for this PR to work?

@natboehm
Copy link
Contributor Author

@vignesh-sankaran not sure about the version but I think we're waiting on this PR to be merged.

@sgrif
Copy link
Contributor

sgrif commented Jul 21, 2017

I'm going to release tomorrow

@vignesh-sankaran
Copy link
Contributor

@sgrif Were you also going to update the Diesel version that crates.io specifies?

@sgrif
Copy link
Contributor

sgrif commented Jul 23, 2017

@natboehm If you rebase you should have everything you need now

@natboehm natboehm force-pushed the add-recent-downloads branch from c6719b7 to 7648e13 Compare July 24, 2017 14:53
@carols10cents carols10cents reopened this Jul 24, 2017
@natboehm natboehm force-pushed the add-recent-downloads branch from 7648e13 to 28c1bbd Compare July 25, 2017 15:26
Copy link
Member

@carols10cents carols10cents left a comment

Choose a reason for hiding this comment

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

Overall this is looking great!!!! This was a lot of work, good job!!!

I've got a few small comments, and there's also:

  • A clippy failure i think we should allow for now
  • A problem with nulls i'll talk to you about in a second - add NULLS LAST to the ordering by recent downloads sql and add a test
  • A few commit messages that can be cleaned up

src/tests/all.rs Outdated
@@ -1,4 +1,4 @@
#![deny(warnings)]
//#![deny(warnings)]
Copy link
Member

Choose a reason for hiding this comment

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

Could you put this back please ❤️ :)

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!!! 😻


await visit('/crates');
const $recentDownloads = findWithAssert('div.recent-downloads:first span.num');
hasText(assert, $recentDownloads, 'Recent:');
Copy link
Member

Choose a reason for hiding this comment

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

Is this test's expected text meant to have a number in it like the assertion on line 61 does?

return (this.get('sort') === 'downloads') ? 'Downloads' : 'Alphabetical';
if (this.get('sort') === 'downloads') {
return 'All-Time Downloads';
} else if (this.get('sort') === 'recent-downloads') {
Copy link
Member

Choose a reason for hiding this comment

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

WDYT about removing the explicit check for 'recent-downloads' and letting the else case handle that here? Kind of like the default Alphabetical in app/controllers/crates.js?

.recent-downloads {
@include display-flex;
@include align-items(center);

Copy link
Member

Choose a reason for hiding this comment

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

Nitpicky: could you remove this empty line please? :)

src/krate.rs Outdated
@@ -39,7 +40,17 @@ use util::{RequestUtils, CargoResult, internal, ChainError, human};
use version::{EncodableVersion, NewVersion};
use {Model, User, Keyword, Version, Category, Badge, Replica};

#[derive(Debug, Clone, Queryable, Identifiable, AsChangeset)]
#[derive(Insertable, Queryable, Identifiable, Associations, AsChangeset)]
Copy link
Member

Choose a reason for hiding this comment

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

Could you add Debug here please? I like having debug on all the things :) hmmmm I think sgrif told me there was a lint for this....

Copy link
Contributor

@sgrif sgrif Jul 25, 2017

Choose a reason for hiding this comment

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

#![deny(missing_debug_implementations, missing_copy_implementations)] 😄

@natboehm natboehm force-pushed the add-recent-downloads branch from e094f52 to 1acfbef Compare July 25, 2017 18:45
@carols10cents carols10cents merged commit 550b3d6 into rust-lang:master Jul 26, 2017
@natboehm natboehm deleted the add-recent-downloads branch September 15, 2017 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants