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 guild_list = wynncraft::guild_list().unwrap();
|
||||||
let conn = establish_connection();
|
let conn = establish_connection();
|
||||||
|
|
||||||
let values = guild_list.into_iter().map(|name| {
|
guild_list.into_iter().for_each(|name| {
|
||||||
thread::sleep_ms(2500);
|
thread::sleep_ms(2500);
|
||||||
Guild { prefix: wynncraft::guild(&name).unwrap().unwrap().prefix, name }
|
println!("Getting {:?}", name);
|
||||||
}).collect::<Vec<_>>();
|
let guild = Guild { prefix: wynncraft::guild(&name).unwrap().unwrap().prefix, name };
|
||||||
for value in values.into_iter() {
|
|
||||||
diesel::insert_into(guilds::table)
|
diesel::insert_into(guilds::table)
|
||||||
.values(&value)
|
.values(&guild)
|
||||||
.on_conflict(guilds::prefix)
|
.on_conflict(guilds::prefix)
|
||||||
.do_nothing()
|
.do_nothing()
|
||||||
.execute(&conn).unwrap();
|
.execute(&conn).unwrap();
|
||||||
}
|
});
|
||||||
|
|
||||||
println!("Guilds updated!");
|
println!("Guilds updated!");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user