-
Notifications
You must be signed in to change notification settings - Fork 647
WIP: Port crates#index
to use Diesel
#600
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE versions ALTER COLUMN yanked DROP NOT NULL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE versions ALTER COLUMN yanked SET NOT NULL; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,8 @@ impl App { | |
.helper_threads(if config.env == ::Env::Production {3} else {1}) | ||
.build(); | ||
let diesel_db_config = r2d2::Config::builder() | ||
.pool_size(if config.env == ::Env::Production {1} else {1}) | ||
.pool_size(if config.env == ::Env::Production {50} else {1}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This 50 is going to have to come down as we discovered yesterday There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought prod had 120 connections available? I told it to not try to keep more than 5 idles at a time so it should never get bad on staging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see. I thought this would mean I couldn't deploy it to staging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, r2d2's naming/behavior/defaults are all really questionable here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could totally take down staging by sending 20 concurrent requests though, but I figured that's not a huge concern. |
||
.min_idle(if config.env == ::Env::Production {5} else {1}) | ||
.helper_threads(if config.env == ::Env::Production {3} else {1}) | ||
.build(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,13 @@ use pg::rows::Row; | |
|
||
use {Model, Crate}; | ||
use db::RequestTransaction; | ||
use schema::*; | ||
use util::{RequestUtils, CargoResult, ChainError}; | ||
use util::errors::NotFound; | ||
|
||
#[derive(Clone)] | ||
#[derive(Clone, Identifiable, Associations)] | ||
#[has_many(crates_categories)] | ||
#[table_name="categories"] | ||
pub struct Category { | ||
pub id: i32, | ||
pub category: String, | ||
|
@@ -21,6 +24,15 @@ pub struct Category { | |
pub crates_cnt: i32, | ||
} | ||
|
||
#[derive(Associations)] | ||
#[belongs_to(Category)] | ||
#[table_name="crates_categories"] | ||
#[allow(dead_code)] // FIXME: Hey @sgrif add better many-to-many support to Diesel, wouldya? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
struct CrateCategory { | ||
crate_id: i32, | ||
category_id: i32, | ||
} | ||
|
||
#[derive(RustcEncodable, RustcDecodable)] | ||
pub struct EncodableCategory { | ||
pub id: String, | ||
|
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.
👍 👍 👍 👍
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.
inb4 prod has a ton of rows where this is null