forked from Skynet/discord-bot
fix: preserve data wherever possible
This commit is contained in:
parent
ab2c695409
commit
3bf085204e
1 changed files with 7 additions and 9 deletions
|
@ -91,8 +91,9 @@ fn get_csv(config: &Config) -> Result<Vec<Csv>, Box<dyn std::error::Error>> {
|
|||
async fn add_users_wolves_csv(db: &Pool<Sqlite>, 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<Sqlite>) {
|
|||
} = server_config;
|
||||
|
||||
// get the data here
|
||||
let result: Vec<WolvesResult> = vec![WolvesResult {
|
||||
id_wolves: "12345".to_string(),
|
||||
email: "ul.wolves2@brendan.ie".to_string(),
|
||||
expiry: "2024-08-31".to_string(),
|
||||
}];
|
||||
let result: Vec<WolvesResult> = vec![];
|
||||
|
||||
for user in result {
|
||||
add_users_wolves(db, &server, &user).await;
|
||||
|
@ -193,8 +190,9 @@ async fn add_users_wolves(db: &Pool<Sqlite>, 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)
|
||||
|
|
Loading…
Reference in a new issue