Skip to content

Port crate/versions over to use Diesel #755

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 1 commit into from
Jul 7, 2017

Conversation

sgrif
Copy link
Contributor

@sgrif sgrif commented Jun 6, 2017

No description provided.

src/krate.rs Outdated
let conn = req.db_conn()?;
let krate = Crate::by_name(crate_name).first::<Crate>(&*conn)?;
let mut versions = Version::belonging_to(&krate).load::<Version>(&*conn)?;
versions.sort_by(|a, b| b.num.cmp(&a.num));
Copy link
Member

Choose a reason for hiding this comment

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

This sorting is getting duplicated in multiple places-- do you think we could make a method that uses diesel that behaves like krate.versions() does now, that would always sort the versions? Or is there some reason why we wouldn't want that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally we'd just do the sort in SQL, it sucks that we can't here. There's no specific reason why we can't have krate.versions, I mostly just wanted to move more behavior off that struct since it's already doing so much. Code that relies on the fact that versions are sorted should make it clear that they care about that fact IMO. I liked the solution in the build info PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carols10cents Did you want me to copy the method from that PR? Or can refactoring that wait until both have been merged?

Copy link
Member

Choose a reason for hiding this comment

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

I'm cool with waiting

@sgrif sgrif force-pushed the sg-port-crate-versions branch 2 times, most recently from 58b3ec8 to 439aa99 Compare July 5, 2017 17:36
@sgrif sgrif force-pushed the sg-port-crate-versions branch from 439aa99 to d4a8337 Compare July 6, 2017 00:30
@carols10cents carols10cents merged commit c05b2ea into rust-lang:master Jul 7, 2017
@sgrif sgrif deleted the sg-port-crate-versions branch July 7, 2017 20:25
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.

3 participants