diff --git a/src/bin/update_data.rs b/src/bin/update_data.rs index 2b1d1f7..1fc25de 100644 --- a/src/bin/update_data.rs +++ b/src/bin/update_data.rs @@ -91,8 +91,9 @@ fn get_csv(config: &Config) -> Result, Box> { async fn add_users_wolves_csv(db: &Pool, server: &GuildId, user: &Csv) { match sqlx::query_as::<_, Wolves>( " - INSERT OR REPLACE INTO wolves (id_wolves, email) - VALUES (?1, ?2) + INSERT INTO wolves (id_wolves, email) + VALUES ($1, $2) + ON CONFLICT(id_wolves) DO UPDATE SET email = $2 ", ) .bind(&user.wolves.id_wolves) @@ -177,11 +178,7 @@ async fn get_wolves(db: &Pool) { } = server_config; // get the data here - let result: Vec = vec![WolvesResult { - id_wolves: "12345".to_string(), - email: "ul.wolves2@brendan.ie".to_string(), - expiry: "2024-08-31".to_string(), - }]; + let result: Vec = vec![]; for user in result { add_users_wolves(db, &server, &user).await; @@ -193,8 +190,9 @@ async fn add_users_wolves(db: &Pool, server: &GuildId, user: &WolvesResu // expiry match sqlx::query_as::<_, Wolves>( " - INSERT OR REPLACE INTO wolves (id_wolves, email) - VALUES (?1, ?2) + INSERT INTO wolves (id_wolves, email) + VALUES ($1, $2) + ON CONFLICT(id_wolves) DO UPDATE SET email = $2 ", ) .bind(&user.id_wolves)