pull/72/head
parent
c8bfc16af8
commit
faa4f713c8
|
@ -16,10 +16,7 @@ impl PickupTime {
|
|||
/// * `date` - Date of pickup time
|
||||
/// * `label` - Type of trash
|
||||
pub fn new(date: BasicDate, label: String) -> PickupTime {
|
||||
PickupTime {
|
||||
date: date,
|
||||
label: label,
|
||||
}
|
||||
PickupTime { date, label }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,15 @@ fn main() {
|
|||
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
||||
|
||||
let db_conn = PgConnection::establish(&database_url)
|
||||
.expect(&format!("Error connecting to {}", database_url));
|
||||
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url));
|
||||
|
||||
// Doing this linearly is good enough I'd say
|
||||
for c in ABC.chars() {
|
||||
if let Ok(streets) = search_streets(&c.to_string()) {
|
||||
insert_into(ivago_streets).values(streets).execute(&db_conn);
|
||||
insert_into(ivago_streets)
|
||||
.values(streets)
|
||||
.execute(&db_conn)
|
||||
.expect("Failed to insert rows.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,9 @@ use rocket_contrib::databases::diesel;
|
|||
#[cfg(feature = "frontend")]
|
||||
use rocket_contrib::serve::StaticFiles;
|
||||
|
||||
pub struct CORS;
|
||||
pub struct Cors;
|
||||
|
||||
impl Fairing for CORS {
|
||||
impl Fairing for Cors {
|
||||
fn info(&self) -> Info {
|
||||
Info {
|
||||
name: "Add CORS headers to responses",
|
||||
|
@ -63,8 +63,9 @@ fn run_db_migrations(rocket: Rocket) -> Result<Rocket, Rocket> {
|
|||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
// This needs to be muted for the frontend feature
|
||||
#[allow(unused_mut)]
|
||||
let mut rocket = rocket::ignite()
|
||||
.attach(CORS)
|
||||
.attach(Cors)
|
||||
.attach(FejDbConn::fairing())
|
||||
.attach(AdHoc::on_attach("Database Migrations", run_db_migrations))
|
||||
.mount("/api/ivago", routes::ivago()) // /api being hardcoded is temporary
|
||||
|
|
Loading…
Reference in New Issue