Make inserts incremental
This commit is contained in:
parent
26558bc3b2
commit
a50b140945
11
src/main.rs
11
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::<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!");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user