Skip to content

Commit f733da7

Browse files
authored
Merge pull request #168 from Preeti9764/all-git
Fetch all github activities
2 parents 378540a + 8f462e6 commit f733da7

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

src/popup.html

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,16 @@ <h4>Organization Name</h4>
135135
<i class="fa fa-question-circle question-icon"></i>
136136
<span class="tooltip-bubble">
137137
<b>Which organization's GitHub activity?</b><br>
138-
Enter the GitHub organization name to fetch activites for. Default is <b>fossasia</b>.
138+
Enter the GitHub organization name to fetch activities for. Leave empty to fetch all your GitHub
139+
activities across all organizations.
139140
Organization name is not case-sensitive.
140141
</span>
141142
</span>
142143
</div>
143144
<div class="flex items-center mt-4 gap-2">
144145
<input id="orgInput" type="text"
145146
class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2"
146-
placeholder="Enter organization name(Default: fossasia)">
147+
placeholder="Enter organization name">
147148
<button id="setOrgBtn" type="button"
148149
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"
149150
style="min-width:60px;">Set</button>
@@ -174,19 +175,23 @@ <h4>Your Github Token</h4>
174175
<i id="tokenEyeIcon" class="fa fa-eye text-gray-600"></i>
175176
</button>
176177
</div>
177-
<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">
178+
<input id="githubToken" type="password"
179+
class="w-full border-2 border-gray-200 bg-gray-200 rounded-xl text-gray-800 p-2 my-2 pr-10"
180+
placeholder="Required for making authenticated requests">
181+
178182

179-
180183

181184
<div class="col s12 my-4 ">
182185
<div class="flex items-center gap-2">
183186
<input type="checkbox" id="showCommits" checked class="form-checkbox h-4 w-4 text-blue-600 ">
184-
<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">
185-
<i class="fa fa-question-circle question-icon"></i>
186-
<span class="tooltip-bubble">
187-
Github Token required.
187+
<label id="showCommitsLabel" for="showCommits"
188+
class="text-gray-700 font-medium text-sm flex items-center gap-1 ">Show commits made within date range
189+
in Open PRs</label> <span class="tooltip-container">
190+
<i class="fa fa-question-circle question-icon"></i>
191+
<span class="tooltip-bubble">
192+
Github Token required.
193+
</span>
188194
</span>
189-
</span>
190195
</div>
191196
</div>
192197

@@ -231,6 +236,7 @@ <h4 class="font-semibold text-xl">Note:</h4>
231236
<li>Please note that some discrepancies may occur in the generated SCRUM. We recommend manually reviewing
232237
and editing the report to ensure accuracy before sharing
233238
</li>
239+
234240
</ul>
235241
</div>
236242
</div>

src/scripts/popup.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ document.addEventListener('DOMContentLoaded', function () {
129129
'githubToken',
130130
'projectName',
131131
'settingsToggle',
132-
132+
133133
];
134134

135135
const radios = document.querySelectorAll('input[name="timeframe"]');
@@ -217,9 +217,7 @@ document.addEventListener('DOMContentLoaded', function () {
217217
generateBtn.addEventListener('click', function () {
218218
// Check org input value before generating report
219219
let org = orgInput.value.trim().toLowerCase();
220-
if (!org) {
221-
org = 'fossasia';
222-
}
220+
// Allow empty org to fetch all GitHub activities
223221
chrome.storage.local.set({ orgName: org }, () => {
224222
generateBtn.innerHTML = '<i class="fa fa-spinner fa-spin"></i> Generating...';
225223
generateBtn.disabled = true;
@@ -379,9 +377,7 @@ document.addEventListener('DOMContentLoaded', function () {
379377
// Auto-update orgName in storage on input change
380378
orgInput.addEventListener('input', function () {
381379
let org = orgInput.value.trim().toLowerCase();
382-
if (!org) {
383-
org = 'fossasia';
384-
}
380+
// Allow empty org to fetch all GitHub activities
385381
chrome.storage.local.set({ orgName: org }, function () {
386382
chrome.storage.local.remove('githubCache'); // Clear cache on org change
387383
});
@@ -390,12 +386,23 @@ document.addEventListener('DOMContentLoaded', function () {
390386
// Add click event for setOrgBtn to set org
391387
setOrgBtn.addEventListener('click', function () {
392388
let org = orgInput.value.trim().toLowerCase();
389+
// Do not default to any org, allow empty string
390+
// if (!org) {
391+
// org = 'fossasia';
392+
// }
393+
console.log('[Org Check] Checking organization:', org);
393394
if (!org) {
394-
org = 'fossasia';
395+
// If org is empty, clear orgName in storage but don't auto-generate report
396+
chrome.storage.local.set({ orgName: '' }, function () {
397+
console.log('[Org Check] Organization cleared from storage');
398+
});
399+
return;
395400
}
401+
396402
setOrgBtn.disabled = true;
397403
const originalText = setOrgBtn.innerHTML;
398404
setOrgBtn.innerHTML = '<i class="fa fa-spinner fa-spin"></i>';
405+
399406
fetch(`https://api.github.com/orgs/${org}`)
400407
.then(res => {
401408
if (res.status === 404) {
@@ -425,6 +432,7 @@ document.addEventListener('DOMContentLoaded', function () {
425432
}
426433
const oldToast = document.getElementById('invalid-org-toast');
427434
if (oldToast) oldToast.parentNode.removeChild(oldToast);
435+
428436
chrome.storage.local.set({ orgName: org }, function () {
429437
// Always clear the scrum report and show org changed message
430438
const scrumReport = document.getElementById('scrumReport');
@@ -454,6 +462,7 @@ document.addEventListener('DOMContentLoaded', function () {
454462
setTimeout(() => {
455463
if (toastDiv.parentNode) toastDiv.parentNode.removeChild(toastDiv);
456464
}, 2500);
465+
457466
});
458467
})
459468
.catch((err) => {

src/scripts/scrumHelper.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ let refreshButton_Placed = false;
1414
let enableToggle = true;
1515
let hasInjectedContent = false;
1616
let scrumGenerationInProgress = false;
17-
let orgName = 'fossasia'; // default
17+
18+
let orgName = '';
19+
1820
function allIncluded(outputTarget = 'email') {
1921
if (scrumGenerationInProgress) {
2022
console.warn('[SCRUM-HELPER]: Scrum generation already in progress, aborting new call.');
@@ -175,8 +177,9 @@ function allIncluded(outputTarget = 'email') {
175177
log('Restored cache from storage');
176178
}
177179

178-
if (items.orgName) {
179-
orgName = items.orgName;
180+
if (typeof items.orgName !== 'undefined') {
181+
orgName = items.orgName || '';
182+
console.log('[SCRUM-HELPER] orgName set to:', orgName);
180183
}
181184
},
182185
);
@@ -324,7 +327,7 @@ function allIncluded(outputTarget = 'email') {
324327
}
325328

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

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

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

403415
try {
@@ -676,6 +688,7 @@ ${lastWeekUl}<br>
676688
${nextWeekUl}<br>
677689
<b>3. What is blocking me from making progress?</b><br>
678690
${userReason}`;
691+
679692
}
680693

681694

@@ -1145,6 +1158,7 @@ async function forceGithubDataRefresh() {
11451158

11461159
// allIncluded('email');
11471160

1161+
11481162
if (window.location.protocol.startsWith('http')) {
11491163
allIncluded('email');
11501164
$('button>span:contains(New conversation)').parent('button').click(() => {
@@ -1177,6 +1191,7 @@ ${prs.map((pr, i) => ` repo${i}: repository(owner: \"${pr.owner}\", name: \"${pr
11771191
pr${i}: pullRequest(number: ${pr.number}) { merged }
11781192
}`).join('\n')}
11791193
}`;
1194+
11801195
try {
11811196
const res = await fetch('https://api.github.com/graphql', {
11821197
method: 'POST',
@@ -1196,4 +1211,5 @@ ${prs.map((pr, i) => ` repo${i}: repository(owner: \"${pr.owner}\", name: \"${pr
11961211
} catch (e) {
11971212
return results;
11981213
}
1199-
}
1214+
}
1215+

0 commit comments

Comments
 (0)