diff --git a/migrations/20240711150547_add_mac.sql b/migrations/20240711150547_add_mac.sql new file mode 100644 index 0000000..3808373 --- /dev/null +++ b/migrations/20240711150547_add_mac.sql @@ -0,0 +1 @@ +ALTER TABLE Member ADD COLUMN macaddress TEXT; \ No newline at end of file diff --git a/migrations/20240813125650_rename_present_to_ispresent.sql b/migrations/20240813125650_rename_present_to_ispresent.sql new file mode 100644 index 0000000..79aab75 --- /dev/null +++ b/migrations/20240813125650_rename_present_to_ispresent.sql @@ -0,0 +1 @@ +ALTER TABLE Attendance RENAME COLUMN present TO ispresent; diff --git a/migrations/20240813130838_rename_present_to_isPresent.sql b/migrations/20240813130838_rename_present_to_isPresent.sql new file mode 100644 index 0000000..4c2936f --- /dev/null +++ b/migrations/20240813130838_rename_present_to_isPresent.sql @@ -0,0 +1 @@ +ALTER TABLE Attendance RENAME COLUMN ispresent TO is_present; diff --git a/src/db/attendance.rs b/src/db/attendance.rs index 724a42b..5ba3a3f 100644 --- a/src/db/attendance.rs +++ b/src/db/attendance.rs @@ -9,5 +9,5 @@ pub struct Attendance { pub date: NaiveDate, pub timein: NaiveTime, pub timeout: NaiveTime, - pub present: bool, + pub is_present: bool, } diff --git a/src/graphql/mutations.rs b/src/graphql/mutations.rs index 9661bf2..d001672 100644 --- a/src/graphql/mutations.rs +++ b/src/graphql/mutations.rs @@ -40,7 +40,7 @@ impl MutationRoot { } - //Mutation for adding Attendance to the Attendance table + //Mutation for adding attendance to the Attendance table async fn add_attendance( &self, ctx: &Context<'_>, @@ -64,19 +64,19 @@ impl MutationRoot { Ok(attendance) } - async fn update_attendance_present( + async fn mark_attendance( &self, ctx: &Context<'_>, id: i32, date: NaiveDate, - present: bool, + is_present: bool, ) -> Result { let pool = ctx.data::>().expect("Pool not found in context"); let attendance = sqlx::query_as::<_, Attendance>( - "UPDATE Attendance SET present = $1 WHERE id = $2 AND date = $3 RETURNING *" + "UPDATE Attendance SET is_present = $1 WHERE id = $2 AND date = $3 RETURNING *" ) - .bind(present) + .bind(is_present) .bind(id) .bind(date) .fetch_one(pool.as_ref()) diff --git a/src/graphql/query.rs b/src/graphql/query.rs index c249783..d8ebfb7 100644 --- a/src/graphql/query.rs +++ b/src/graphql/query.rs @@ -11,7 +11,7 @@ pub struct QueryRoot; #[Object] impl QueryRoot { - //Query for retrieving the Members + //Query for retrieving the members async fn get_member(&self, ctx: &Context<'_>) -> Result, sqlx::Error> { let pool = ctx.data::>().expect("Pool not found in context"); let users = sqlx::query_as::<_, Member>("SELECT * FROM Member") @@ -20,7 +20,7 @@ impl QueryRoot { Ok(users) } - //Query for retrieving the Attendance based on date + //Query for retrieving the attendance based on date async fn get_attendance( &self, ctx: &Context<'_>,