Skip to content

Commit

Permalink
renames update_attendance_present to mark_attendance, fixes documenta…
Browse files Browse the repository at this point in the history
…tion issues
  • Loading branch information
Wreck-X committed Aug 13, 2024
1 parent daf8430 commit 390e43f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions migrations/20240711150547_add_mac.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Member ADD COLUMN macaddress TEXT;
1 change: 1 addition & 0 deletions migrations/20240813125650_rename_present_to_ispresent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Attendance RENAME COLUMN present TO ispresent;
1 change: 1 addition & 0 deletions migrations/20240813130838_rename_present_to_isPresent.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE Attendance RENAME COLUMN ispresent TO is_present;
2 changes: 1 addition & 1 deletion src/db/attendance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ pub struct Attendance {
pub date: NaiveDate,
pub timein: NaiveTime,
pub timeout: NaiveTime,
pub present: bool,
pub is_present: bool,
}
10 changes: 5 additions & 5 deletions src/graphql/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>,
Expand All @@ -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<Attendance,sqlx::Error> {
let pool = ctx.data::<Arc<PgPool>>().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())
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Member>, sqlx::Error> {
let pool = ctx.data::<Arc<PgPool>>().expect("Pool not found in context");
let users = sqlx::query_as::<_, Member>("SELECT * FROM Member")
Expand All @@ -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<'_>,
Expand Down

0 comments on commit 390e43f

Please sign in to comment.