Skip to content

feat: added member summary command and apply leave command#105

Open
tejasai2007 wants to merge 1 commit into
amfoss:developfrom
tejasai2007:develop
Open

feat: added member summary command and apply leave command#105
tejasai2007 wants to merge 1 commit into
amfoss:developfrom
tejasai2007:develop

Conversation

@tejasai2007

Copy link
Copy Markdown

Developed member summary and apply leave commands to enforce strict attendance tracking and leave limits.

@tejasai2007
tejasai2007 force-pushed the develop branch 9 times, most recently from f4df892 to 8b2e600 Compare March 14, 2026 10:32
@tejasai2007

Copy link
Copy Markdown
Author

@hrideshmg can you please review this pr

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds new Discord slash commands and GraphQL client functionality to support member summaries and leave application/approval workflows for attendance tracking.

Changes:

  • Introduces /member_summary and /apply_leave slash commands.
  • Adds GraphQL query/mutation methods and models for member summaries and leave tracking/approval.
  • Implements reaction-based leave approval flow on ✅ reactions.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/tasks/status_update.rs Minor formatting updates in break/year label rendering.
src/main.rs Adds ✅ reaction-based leave approval handling in the event handler.
src/graphql/queries.rs Adds member summary + leave count fetching GraphQL queries.
src/graphql/mutations.rs Adds leave application + approval GraphQL mutations.
src/graphql/models.rs Adds structs for member summary and leave records.
src/graphql/mod.rs Exposes the new mutations module.
src/config.rs Minor formatting change in env var loading.
src/commands/summary.rs New /member_summary command and default date range logic.
src/commands/mod.rs Registers new commands.
src/commands/apply_leave.rs New /apply_leave command and leave request embed posting.

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

Comment thread src/main.rs
Comment on lines 157 to +160
FullEvent::ReactionAdd { add_reaction } => {
handle_reaction(ctx, add_reaction, data, true).await?;
if add_reaction.user_id == Some(ctx.cache.current_user().id) {
return Ok(());
}
Comment thread src/main.rs
Comment on lines +181 to +187
if let Some(line) = description.lines().find(|l| l.contains("User:")) {
let discord_id = line
.replace("**User:**", "")
.replace("<@", "")
.replace(">", "")
.trim()
.to_string();
Comment thread src/graphql/queries.rs
Comment on lines +210 to +212
let total_days = (end_date - start_date).num_days().max(1);

let update_percent = (updates as f32 * 100.0) / total_days as f32;
Comment thread src/graphql/queries.rs
Comment on lines +264 to +267
let leaves: LeaveCountRecord = LeaveCountRecord {
discord_id: discord_id.to_string(),
leave_count: json["data"]["members"]["leaveCount"].as_i64().unwrap_or(0) as i32,
};
Comment thread src/graphql/mutations.rs
Comment on lines +80 to +84
approveLeave(
discordId: $discord_id,
approvedBy: $mentor_discord_id,

) {
Comment on lines +13 to +19
let discord_id = ctx.author().id.to_string();

let duration = duration.unwrap_or(1);
ctx.data()
.graphql_client
.apply_leave(&discord_id, start_date, duration, reason)
.await?;
Comment on lines +21 to +41
let embed = if duration == 1 {
CreateEmbed::new()
.title("📝 Leave Request")
.description(format!(
"**User :** <@{}>\n\
**Start Date :** {}\n\
**Duration :** {} day\n\n\
",
discord_id, start_date, duration
))
} else {
CreateEmbed::new()
.title("📝 Leave Request")
.description(format!(
"**User:** <@{}>\n\
**Start Date:** {}\n\
**Duration:** {} days\n\n\
React with ✅ to approve.",
discord_id, start_date, duration
))
};
Comment on lines +48 to +57
if duration != 1 {
message
.react(ctx, serenity::ReactionType::Unicode("✅".into()))
.await?;

message
.react(ctx, serenity::ReactionType::Unicode("❌".into()))
.await?;
}
ctx.say("Leave request submitted.").await?;
Comment thread src/commands/summary.rs
Comment on lines +22 to +41
let time = Local::now();
let year = time.year();
let month = time.month();
let end = time.date_naive();

let (target_year, target_month) = if end.day() == 1 {
if month == 1 {
(year - 1, 12)
} else {
(year, month - 1)
}
} else {
(year, month)
};

let start = NaiveDate::from_ymd_opt(target_year, target_month, 1)
.ok_or_else(|| anyhow::anyhow!("Invalid date"))?;

(start, end)
}
Comment thread src/commands/summary.rs
anyhow::anyhow!("Either provide both start and end dates, or none.").into(),
);
}
};
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.

2 participants