2021-04-17 23:20:41 +02:00
|
|
|
use diesel::{insert_into, Connection, PgConnection, RunQueryDsl};
|
2021-05-13 15:42:05 +02:00
|
|
|
use fej::{ivago::search_streets, schema::ivago_streets::dsl::*};
|
2021-04-17 23:20:41 +02:00
|
|
|
|
|
|
|
const ABC: &str = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
|
|
|
|
|
|
|
let db_conn = PgConnection::establish(&database_url)
|
2021-05-11 22:11:35 +02:00
|
|
|
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url));
|
2021-04-17 23:20:41 +02:00
|
|
|
|
|
|
|
// Doing this linearly is good enough I'd say
|
|
|
|
for c in ABC.chars() {
|
|
|
|
if let Ok(streets) = search_streets(&c.to_string()) {
|
2021-05-11 22:11:35 +02:00
|
|
|
insert_into(ivago_streets)
|
|
|
|
.values(streets)
|
|
|
|
.execute(&db_conn)
|
|
|
|
.expect("Failed to insert rows.");
|
2021-04-17 23:20:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|