Skip to content

Fetch all github activities #168

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

Merged
merged 8 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ <h4>Organization Name</h4>
<i class="fa fa-question-circle question-icon"></i>
<span class="tooltip-bubble">
<b>Which organization's GitHub activity?</b><br>
Enter the GitHub organization name to fetch activites for. Default is <b>fossasia</b>.
Enter the GitHub organization name to fetch activities for. Leave empty to fetch all your GitHub
activities across all organizations.
Organization name is not case-sensitive.
</span>
</span>
</div>
<div class="flex items-center mt-4 gap-2">
<input id="orgInput" type="text"
class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2"
placeholder="Enter organization name(Default: fossasia)">
placeholder="Enter organization name">
<button id="setOrgBtn" type="button"
class="px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-xl text-base my-2 h-[44px] flex-shrink-0"
style="min-width:60px;">Set</button>
Expand Down Expand Up @@ -174,19 +175,23 @@ <h4>Your Github Token</h4>
<i id="tokenEyeIcon" class="fa fa-eye text-gray-600"></i>
</button>
</div>
<input id="githubToken" type="password" class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2 pr-10" placeholder="Required for making authenticated requests">
<input id="githubToken" type="password"
class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2 pr-10"
placeholder="Required for making authenticated requests">




<div class="col s12 my-4 ">
<div class="flex items-center gap-2">
<input type="checkbox" id="showCommits" checked class="form-checkbox h-4 w-4 text-blue-600 ">
<label id="showCommitsLabel" for="showCommits" class="text-gray-700 font-medium text-sm flex items-center gap-1 ">Show commits made within date range in Open PRs</label> <span class="tooltip-container">
<i class="fa fa-question-circle question-icon"></i>
<span class="tooltip-bubble">
Github Token required.
<label id="showCommitsLabel" for="showCommits"
class="text-gray-700 font-medium text-sm flex items-center gap-1 ">Show commits made within date range
in Open PRs</label> <span class="tooltip-container">
<i class="fa fa-question-circle question-icon"></i>
<span class="tooltip-bubble">
Github Token required.
</span>
</span>
</span>
</div>
</div>

Expand Down Expand Up @@ -231,6 +236,7 @@ <h4 class="font-semibold text-xl">Note:</h4>
<li>Please note that some discrepancies may occur in the generated SCRUM. We recommend manually reviewing
and editing the report to ensure accuracy before sharing
</li>

</ul>
</div>
</div>
Expand Down
25 changes: 17 additions & 8 deletions src/scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ document.addEventListener('DOMContentLoaded', function () {
'githubToken',
'projectName',
'settingsToggle',

];

const radios = document.querySelectorAll('input[name="timeframe"]');
Expand Down Expand Up @@ -217,9 +217,7 @@ document.addEventListener('DOMContentLoaded', function () {
generateBtn.addEventListener('click', function () {
// Check org input value before generating report
let org = orgInput.value.trim().toLowerCase();
if (!org) {
org = 'fossasia';
}
// Allow empty org to fetch all GitHub activities
chrome.storage.local.set({ orgName: org }, () => {
generateBtn.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating...';
generateBtn.disabled = true;
Expand Down Expand Up @@ -379,9 +377,7 @@ document.addEventListener('DOMContentLoaded', function () {
// Auto-update orgName in storage on input change
orgInput.addEventListener('input', function () {
let org = orgInput.value.trim().toLowerCase();
if (!org) {
org = 'fossasia';
}
// Allow empty org to fetch all GitHub activities
chrome.storage.local.set({ orgName: org }, function () {
chrome.storage.local.remove('githubCache'); // Clear cache on org change
});
Expand All @@ -390,12 +386,23 @@ document.addEventListener('DOMContentLoaded', function () {
// Add click event for setOrgBtn to set org
setOrgBtn.addEventListener('click', function () {
let org = orgInput.value.trim().toLowerCase();
// Do not default to any org, allow empty string
// if (!org) {
// org = 'fossasia';
// }
console.log('[Org Check] Checking organization:', org);
if (!org) {
org = 'fossasia';
// If org is empty, clear orgName in storage but don't auto-generate report
chrome.storage.local.set({ orgName: '' }, function () {
console.log('[Org Check] Organization cleared from storage');
});
return;
}

setOrgBtn.disabled = true;
const originalText = setOrgBtn.innerHTML;
setOrgBtn.innerHTML = '<i class="fa fa-spinner fa-spin"></i>';

fetch(`https://api.github.com/orgs/${org}`)
.then(res => {
if (res.status === 404) {
Expand Down Expand Up @@ -425,6 +432,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
const oldToast = document.getElementById('invalid-org-toast');
if (oldToast) oldToast.parentNode.removeChild(oldToast);

chrome.storage.local.set({ orgName: org }, function () {
// Always clear the scrum report and show org changed message
const scrumReport = document.getElementById('scrumReport');
Expand Down Expand Up @@ -454,6 +462,7 @@ document.addEventListener('DOMContentLoaded', function () {
setTimeout(() => {
if (toastDiv.parentNode) toastDiv.parentNode.removeChild(toastDiv);
}, 2500);

});
})
.catch((err) => {
Expand Down
30 changes: 23 additions & 7 deletions src/scripts/scrumHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ let refreshButton_Placed = false;
let enableToggle = true;
let hasInjectedContent = false;
let scrumGenerationInProgress = false;
let orgName = 'fossasia'; // default

let orgName = '';

function allIncluded(outputTarget = 'email') {
if (scrumGenerationInProgress) {
console.warn('[SCRUM-HELPER]: Scrum generation already in progress, aborting new call.');
Expand Down Expand Up @@ -175,8 +177,9 @@ function allIncluded(outputTarget = 'email') {
log('Restored cache from storage');
}

if (items.orgName) {
orgName = items.orgName;
if (typeof items.orgName !== 'undefined') {
orgName = items.orgName || '';
console.log('[SCRUM-HELPER] orgName set to:', orgName);
}
},
);
Expand Down Expand Up @@ -324,7 +327,7 @@ function allIncluded(outputTarget = 'email') {
}

async function fetchGithubData() {
const cacheKey = `${githubUsername}-${orgName}-${startingDate}-${endingDate}`;
const cacheKey = `${githubUsername}-${startingDate}-${endingDate}-${orgName || 'all'}`;

if (githubCache.fetching || (githubCache.cacheKey === cacheKey && githubCache.data)) {
log('Fetch already in progress or data already fetched. Skipping fetch.');
Expand Down Expand Up @@ -396,8 +399,17 @@ function allIncluded(outputTarget = 'email') {
log('Making public requests');
}

let issueUrl = `https://api.github.com/search/issues?q=author%3A${githubUsername}+org%3A${orgName}+updated%3A${startingDate}..${endingDate}&per_page=100`;
let prUrl = `https://api.github.com/search/issues?q=commenter%3A${githubUsername}+org%3A${orgName}+updated%3A${startingDate}..${endingDate}&per_page=100`;
// Build org part for query only if orgName is set and not empty
console.log('[SCRUM-HELPER] orgName before API query:', orgName);
console.log('[SCRUM-HELPER] orgName type:', typeof orgName);
console.log('[SCRUM-HELPER] orgName length:', orgName ? orgName.length : 0);
let orgPart = orgName && orgName.trim() ? `+org%3A${orgName}` : '';
console.log('[SCRUM-HELPER] orgPart for API:', orgPart);
console.log('[SCRUM-HELPER] orgPart length:', orgPart.length);
let issueUrl = `https://api.github.com/search/issues?q=author%3A${githubUsername}${orgPart}+updated%3A${startingDate}..${endingDate}&per_page=100`;
let prUrl = `https://api.github.com/search/issues?q=commenter%3A${githubUsername}${orgPart}+updated%3A${startingDate}..${endingDate}&per_page=100`;
console.log('[SCRUM-HELPER] issueUrl:', issueUrl);
console.log('[SCRUM-HELPER] prUrl:', prUrl);
let userUrl = `https://api.github.com/users/${githubUsername}`;

try {
Expand Down Expand Up @@ -676,6 +688,7 @@ ${lastWeekUl}<br>
${nextWeekUl}<br>
<b>3. What is blocking me from making progress?</b><br>
${userReason}`;

}


Expand Down Expand Up @@ -1145,6 +1158,7 @@ async function forceGithubDataRefresh() {

// allIncluded('email');


if (window.location.protocol.startsWith('http')) {
allIncluded('email');
$('button>span:contains(New conversation)').parent('button').click(() => {
Expand Down Expand Up @@ -1177,6 +1191,7 @@ ${prs.map((pr, i) => ` repo${i}: repository(owner: \"${pr.owner}\", name: \"${pr
pr${i}: pullRequest(number: ${pr.number}) { merged }
}`).join('\n')}
}`;

try {
const res = await fetch('https://api.github.com/graphql', {
method: 'POST',
Expand All @@ -1196,4 +1211,5 @@ ${prs.map((pr, i) => ` repo${i}: repository(owner: \"${pr.owner}\", name: \"${pr
} catch (e) {
return results;
}
}
}