From 2b86fa58e4f48b537b97f202f241561ae853b8f5 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Fri, 27 Oct 2023 03:00:51 +0100 Subject: [PATCH] fix: wolves ID is numeric --- src/bin/update_data.rs | 6 +++--- src/lib.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/update_data.rs b/src/bin/update_data.rs index 8bb25f4..b89c284 100644 --- a/src/bin/update_data.rs +++ b/src/bin/update_data.rs @@ -99,7 +99,7 @@ async fn update_ldap(config: &Config, db: &Pool) { impl From<&WolvesResultUser> for AccountWolves { fn from(input: &WolvesResultUser) -> Self { AccountWolves { - id_wolves: input.wolves_id.to_owned(), + id_wolves: input.wolves_id, id_student: input.student_id.to_owned(), email: input.email.to_owned(), expiry: input.expiry.to_owned(), @@ -112,7 +112,7 @@ impl From<&WolvesResultUser> for AccountWolves { #[derive(Deserialize, Serialize, Debug)] struct WolvesResultUser { committee: String, - wolves_id: String, + wolves_id: i64, first_name: String, last_name: String, email: String, @@ -163,7 +163,7 @@ async fn update_account(db: &Pool, account: &AccountWolves) { VALUES (?1, ?2, ?3, ?4, ?5, ?6) ", ) - .bind(&account.id_wolves) + .bind(account.id_wolves) .bind(&account.id_student) .bind(&account.email) .bind(&account.expiry) diff --git a/src/lib.rs b/src/lib.rs index 532c7d7..5e840f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ use tide::prelude::*; #[derive(Debug, Deserialize, Serialize, sqlx::FromRow)] pub struct AccountWolves { - pub id_wolves: String, + pub id_wolves: i64, pub id_student: Option, pub email: String, pub expiry: String, @@ -69,7 +69,7 @@ pub async fn db_init(config: &Config) -> Result, Error> { sqlx::query( "CREATE TABLE IF NOT EXISTS accounts_wolves ( - id_wolves text PRIMARY KEY, + id_wolves integer PRIMARY KEY, id_student text, email text NOT NULL, expiry text NOT NULL, @@ -87,7 +87,7 @@ pub async fn db_init(config: &Config) -> Result, Error> { date_iso text NOT NULL, date_expiry text NOT NULL, name_first text NOT NULL, - name_surname integer NOT NULL, + name_surname text NOT NULL, id_student text NOT NULL )", )