Skip to content

Leave tracking from amD#170

Open
naveensrinivas282 wants to merge 7 commits intoamfoss:developfrom
naveensrinivas282:leave_tracking
Open

Leave tracking from amD#170
naveensrinivas282 wants to merge 7 commits intoamfoss:developfrom
naveensrinivas282:leave_tracking

Conversation

@naveensrinivas282
Copy link
Copy Markdown

@naveensrinivas282 naveensrinivas282 commented Feb 19, 2026

This PR

  • creates a table Leave for
    • mutations leave_application and approve_leave
    • query leave_count
  • add discord_id optional param for Member object so amD can query using discord_id itself

leave_count can be called via member for specific member or allMembers to access leave records of all members

These are currently meant only to be accessed by amD for marking and fetching leaves

@naveensrinivas282
Copy link
Copy Markdown
Author

@hrideshmg Could you review this please ?

Comment thread src/graphql/queries/member_queries.rs Outdated
}

/// Fetch the details of the currently logged in member
// Fetch the details of the currently logged in member
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this changed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mb, I didn't know about the doc comments
Reverted now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it isn't?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces leave tracking functionality to support the amD Discord bot by creating a Leave table in the database and adding corresponding GraphQL mutation and query operations. The changes enable tracking member leaves with approval workflows and querying leave counts within date ranges.

Changes:

  • Created a Leave database table with foreign key references to Member via discord_id, including constraints for leave approval validation
  • Added mark_leave mutation to record new leave entries with discord_id, reason, duration, and optional approver
  • Added leave_count query method to Member type for calculating total leave duration within a date range
  • Extended the member query to accept discord_id as an optional parameter alongside existing member_id and email options

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 14 comments.

File Description
migrations/20260214152404_create_leave_table.sql Creates Leave table schema with foreign keys, defaults, and constraints including self-approval prevention
src/models/attendance.rs Defines MarkLeaveInput, MarkLeaveOutput, and LeaveCountOutput structs for GraphQL API
src/graphql/mutations/attendance_mutations.rs Implements mark_leave mutation to insert leave records with current timestamp
src/graphql/queries/member_queries.rs Adds discord_id parameter to member query and implements leave_count resolver on Member type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/graphql/queries/member_queries.rs Outdated
Comment thread migrations/20260214152404_create_leave_table.sql Outdated
Comment thread src/graphql/mutations/attendance_mutations.rs Outdated
Comment thread src/graphql/mutations/attendance_mutations.rs
Comment thread src/graphql/queries/member_queries.rs Outdated
Comment thread src/graphql/mutations/attendance_mutations.rs Outdated
Comment thread src/graphql/queries/member_queries.rs Outdated
Comment on lines +404 to +409
async fn leave_count(
&self,
ctx: &Context<'_>,
start_date: NaiveDate,
end_date: NaiveDate,
) -> Result<LeaveCountOutput> {
Copy link
Copy Markdown
Member

@hrideshmg hrideshmg Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave should be a nested object with two methods under it that return leave_count and records respectively as we need to be able to query on which days the member took a leave.

See the records and updateCount methods under StatusInfo for reference.

Copy link
Copy Markdown
Member

@hrideshmg hrideshmg Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still unresolved, i don't see a nested object or the records query

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave_count can be called through members and allMembers, so there should be no need for a different records query for all members leave count

@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
Comment thread src/graphql/queries/member_queries.rs Outdated
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
@amfoss amfoss deleted a comment from Copilot AI Feb 22, 2026
Comment thread src/graphql/mutations/attendance_mutations.rs Outdated
@naveensrinivas282
Copy link
Copy Markdown
Author

@hrideshmg I've made the requested changes, could you please review now

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/graphql/mutations/attendance_mutations.rs
Comment thread src/graphql/mutations/attendance_mutations.rs
Comment thread src/graphql/queries/member_queries.rs Outdated
Comment thread src/graphql/queries/member_queries.rs Outdated
Comment thread migrations/20260214152404_create_leave_table.sql
Comment thread migrations/20260214152404_create_leave_table.sql Outdated
Comment thread src/graphql/mutations/attendance_mutations.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from_date DATE DEFAULT CURRENT_DATE NOT NULL,
duration INT DEFAULT 1 NOT NULL,
reason TEXT NOT NULL,
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Comment on lines +4 to +9
discord_id VARCHAR(255) REFERENCES Member(discord_id) ON DELETE CASCADE,
from_date DATE DEFAULT CURRENT_DATE NOT NULL,
duration INT DEFAULT 1 NOT NULL,
reason TEXT NOT NULL,
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
approved_by VARCHAR(255) REFERENCES Member(discord_id) ON DELETE SET NULL,
Comment thread src/models/attendance.rs
Comment on lines +25 to +33
#[derive(SimpleObject, FromRow)]
pub struct MarkLeaveOutput {
pub discord_id: String,
pub from_date: NaiveDate,
pub applied_at: NaiveDateTime,
pub reason: String,
pub duration: i32,
pub approved_by: Option<String>,
}
let discord_id = self
.discord_id
.as_ref()
.expect("Leave count needs discord_id");
start_date: NaiveDate,
end_date: NaiveDate,
) -> Result<i64> {
let pool = ctx.data::<Arc<PgPool>>().expect("Pool must be in context.");
Comment on lines +120 to +121
.fetch_one(pool.as_ref())
.await?;
-- Leave table for tracking leaves
CREATE TABLE Leave (
leave_id SERIAL PRIMARY KEY,
discord_id VARCHAR(255) REFERENCES Member(discord_id) ON DELETE CASCADE,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants