Make inserts incremental

This commit is contained in:
Sakuhl 2018-01-15 15:16:45 +01:00
parent 26558bc3b2
commit a50b140945

View File

@ -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::<Vec<_>>();
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!");