-
Notifications
You must be signed in to change notification settings - Fork 677
Fixes #962 Backend: add "most_recently_downloaded" to 'summary' endpoint #1101
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
Conversation
src/krate/mod.rs
Outdated
| use schema::crates::dsl::*; | ||
| use diesel::expression::DayAndMonthIntervalDsl; | ||
| use diesel::types::{BigInt, Nullable}; | ||
| use diesel::expression::functions::date_and_time::{date, now}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use diesel::expression::{date, now};
src/krate/mod.rs
Outdated
| use diesel::expression::DayAndMonthIntervalDsl; | ||
| use diesel::types::{BigInt, Nullable}; | ||
| use diesel::expression::functions::date_and_time::{date, now}; | ||
| use diesel::expression::sql_literal::sql; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use diesel::expression::sql;
src/krate/mod.rs
Outdated
| ), | ||
| ) | ||
| .group_by(id) | ||
| .order(recent_downloads.clone().desc().nulls_last()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we cloning this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good point. Bad copy pasta.
src/tests/krate.rs
Outdated
| } | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️
| let mut response = ok_resp!(middle.call(&mut req)); | ||
| let json: SummaryResponse = ::json(&mut response); | ||
|
|
||
| assert_eq!(json.num_crates, 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like you need to fix this?
| "most_recent_downloads" | ||
| ); | ||
| assert_eq!(json.popular_keywords[0].keyword, "popular"); | ||
| assert_eq!(json.popular_categories[0].category, "Category 1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like you need to fix this?
src/tests/krate.rs
Outdated
| use self::diesel::prelude::*; | ||
| use serde_json; | ||
| use semver; | ||
| use chrono::Utc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you sort these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
src/krate/mod.rs
Outdated
| use diesel::expression::DayAndMonthIntervalDsl; | ||
| use diesel::types::{BigInt, Nullable}; | ||
| use diesel::expression::{date, now}; | ||
| use diesel::expression::sql; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you sort these and squash all the expression imports into one
- add tests for total_downloads and just updated - sort imports
|
bors: r+ |
Build succeeded |
Description
Adds "most_recently_downloaded" property to JSON response returned from
api/v1/summaryAdds tests for
api/v1/summaryendpoint