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

Enhance User Access Token Flow with PR Count Tracking #16

Closed
wants to merge 3 commits into from

Conversation

mitgajera
Copy link

Overview

This pull request (PR) introduces improvements to the user authentication process by including the retrieval and updating of pull request (PR) counts for users during the access token flow.

Issue fixed: #14

Changes Made

  • New Functionality: Added a getPullRequestCount function that retrieves the total count of pull requests authored by the user from GitHub's API.
  • User Model Update: Updated the user schema to include a prCount field, initialized to 0 for new users.
  • Access Token Flow Update: Modified the getAccessToken function to:
    • Create a new user if they do not exist in the database.
    • Retrieve the user's PR count after user creation or lookup.
    • Update the user's PR count in the database accordingly.

Why This Change?

By keeping track of the number of pull requests, we can better evaluate user engagement and contributions within our application. This enhancement will enable us to use this data for analytics and user recognition features in future iterations.

Testing

  • Manually tested the access token retrieval process with both new and existing users.
  • Verified that the PR count updates correctly in the database.

// Function to fetch pull request count
const getPullRequestCount = async (githubId, accessToken) => {
try {
const response = await axios.get(`https://api.github.com/search/pulls?q=author:${githubId}+is:public`, {
Copy link
Member

Choose a reason for hiding this comment

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

why fetching user's all prs, we don't want his all pr count, we want pr counts of our projects, so you can remove this thing

// router.post('/logout', controller.logout); // Add logout route
router.get('/access_token', controller.getAccessToken); // Add access token route
// GitHub authentication routes
router.get('/github', passport.authenticate('github', { scope: ['user:email'] }));
Copy link
Member

Choose a reason for hiding this comment

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

comment these routes

@jalaym825
Copy link
Member

hey @mitgajera
you messed up with the code base with auto formatting, can you please create a new pr and turn of auto formatting in your ide, it's hard to track changes, also keep your fork up to date.

@jalaym825
Copy link
Member

@mitgajera good work, but please keep small changes in a single commit and don't include changes which are not relatable to issue, you can create separate issue for that.

@mitgajera
Copy link
Author

@jalaym825
Ok I will work on it.

@jalaym825
Copy link
Member

closing the pr for now, fix all things and raise new pr.

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.

add closed, opened, merged pr count in user schema
2 participants