From a50b1409457398c0e514e645ce5a797bf4a2e91b Mon Sep 17 00:00:00 2001 From: Sakuhl <2012collector@gmail.com> Date: Mon, 15 Jan 2018 15:16:45 +0100 Subject: [PATCH] Make inserts incremental --- src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 57c8218..d18f612 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,17 +40,16 @@ fn main() { let guild_list = wynncraft::guild_list().unwrap(); let conn = establish_connection(); - let values = guild_list.into_iter().map(|name| { + guild_list.into_iter().for_each(|name| { thread::sleep_ms(2500); - Guild { prefix: wynncraft::guild(&name).unwrap().unwrap().prefix, name } - }).collect::>(); - for value in values.into_iter() { + println!("Getting {:?}", name); + let guild = Guild { prefix: wynncraft::guild(&name).unwrap().unwrap().prefix, name }; diesel::insert_into(guilds::table) - .values(&value) + .values(&guild) .on_conflict(guilds::prefix) .do_nothing() .execute(&conn).unwrap(); - } + }); println!("Guilds updated!");