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

Updated the projectController.js file to make the necessary modifications as mentioned in issue #98 #99

Open
wants to merge 6 commits into
base: feature/webiu-2024
Choose a base branch
from

Conversation

ritankarsaha
Copy link

Fixes #98
Modified the projectController.js file to make the necessary modifications and ensure the robustness, maintainability and readability of the code.

Description

-Header Extraction: Common headers are extracted to avoid repetition.
-Promise.allSettled: This allows continuing if some API calls fail.
-map Simplification: Instead of copying unnecessary data, it retrieves essential repository details.
-Fallbacks for Optional Fields: Added default values for description, open_issues_count, and stargazers_count for missing data.

Screenshot 2024-11-03 at 2 22 21 PM

The screenshot shows that the webpage works properly and takes load correctly after all the changes.

Screen.Recording.2024-11-03.at.2.22.57.PM.mov

The screen recording shows that the webpage remains unaffected and works properly, fetches data properly after all the changes that has been made

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [x ] My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [x ] All new and existing tests have passed and it does not give any unexpected error for the same.

@rajutkarsh07
Copy link
Collaborator

@ritankarsaha fix the CI for the backend it is failing

@ritankarsaha
Copy link
Author

@ritankarsaha fix the CI for the backend it is failing

Yeah will fix this and push a new commit into the PR. Thanks

@ritankarsaha
Copy link
Author

@rajutkarsh07 Made the necessary modifications and pushed a new commit into the PR.

The CI error occurs because the GITHUB_ACCESS_TOKEN is not defined in the environment during the test run.

I can Update your projectController.js to allow tests to run without requiring a real GITHUB_ACCESS_TOKEN.

const axios = require('axios');
const accessToken = process.env.GITHUB_ACCESS_TOKEN || 'test-token'; // Fallback for tests

if (process.env.NODE_ENV !== 'test' && !accessToken) {
  throw new Error("GITHUB_ACCESS_TOKEN is not defined in the environment.");
}

const GITHUB_API_URL = 'https://api.github.com';
const headers = {
  Authorization: `token ${accessToken}`,
};

This allows tests to run in the test environment without requiring a real token.
Should I do this and push the changes ? or let it as it be ? , because including this would i guess bring down the code quality un-necessarily.

@rajutkarsh07
Copy link
Collaborator

if adding this will fix the CI then add this line

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