Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This resolves the issue "Streaks starts at 0" #40

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Harshith-2208
Copy link

@Harshith-2208 Harshith-2208 commented Feb 21, 2025

Closes #36 The issue was "Streaks starts at 0"
I have added an if condition in the status_update.rs file which will check if the streak is less than 1, If satisfied will set the streak to 1. It is satisfied for all members who missed a status update.

if current_streak < 1 {
                member.streak[0].current_streak = 1;
                debug!("Setting streak to 1 for {}", member.name);
            }

@hrideshmg
Copy link
Member

Hi Harshith, next time use the "closes" format to automatically link the PR to the issue. Also i thought @AadarshM07 was working on this issue?

I'll leave the review of the actual change to @ivinjabraham

@Harshith-2208 Harshith-2208 changed the title Issue#36 closes #36 Feb 26, 2025
@ivinjabraham
Copy link
Member

ivinjabraham commented Feb 28, 2025

Hey @Harshith-2208, I believe you misunderstood Hridesh. He meant put the "closes/fixes/address" keyword in the PR body, not the PR title.

Refer: https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue

@ivinjabraham
Copy link
Member

We really shouldn't be manipulating the data ourselves, we should just use the returned data from Root.

@ivinjabraham ivinjabraham marked this pull request as draft February 28, 2025 05:55
@Harshith-2208
Copy link
Author

I have changed the old code with the new i the recent commit, I hope it works.

if current_streak < 1 {
                increment_streak(&mut member)
                debug!("Setting streak to 1 for {}", member.name);
            }

@Harshith-2208 Harshith-2208 changed the title closes #36 This resolves the issue "Streaks starts at 0" Mar 2, 2025
@Harshith-2208 Harshith-2208 marked this pull request as ready for review March 2, 2025 19:20
@ivinjabraham
Copy link
Member

Not quite. The issue is actually in src/graphql/queries.rs, in the implementation of increment_streak:

    // Handle the streak vector
    if member.streak.is_empty() {
        // If the streak vector is empty, add a new Streak object with both values set to 1
        member.streak.push(Streak {
            current_streak: 1,
            max_streak: 1,
        });
    } else {
        // Otherwise, increment the current_streak for each Streak and update max_streak if necessary
        for streak in &mut member.streak {
            streak.current_streak += 1;
            if streak.current_streak > streak.max_streak {
                streak.max_streak = streak.current_streak;
            }
        }
    }

Instead of manually setting the values ourselves, we should just use the values Root returns.

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.

Streaks start at 0
3 participants