Skip to content

Commit 8f462e6

Browse files
committed
correctly fetching all github actvites
1 parent 9bb4d2b commit 8f462e6

File tree

3 files changed

+35
-40
lines changed

3 files changed

+35
-40
lines changed

src/popup.html

Lines changed: 14 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

src/scripts/popup.js

Lines changed: 3 additions & 7 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
});

src/scripts/scrumHelper.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ let scrumGenerationInProgress = false;
1818
let orgName = '';
1919

2020
function allIncluded(outputTarget = 'email') {
21-
22-
23-
24-
25-
2621
if (scrumGenerationInProgress) {
2722
console.warn('[SCRUM-HELPER]: Scrum generation already in progress, aborting new call.');
2823
return;
@@ -182,10 +177,10 @@ function allIncluded(outputTarget = 'email') {
182177
log('Restored cache from storage');
183178
}
184179

185-
if (typeof items.orgName !== 'undefined') {
186-
orgName = items.orgName || '';
187-
console.log('[SCRUM-HELPER] orgName set to:', orgName);
188-
}
180+
if (typeof items.orgName !== 'undefined') {
181+
orgName = items.orgName || '';
182+
console.log('[SCRUM-HELPER] orgName set to:', orgName);
183+
}
189184
},
190185
);
191186
}
@@ -332,7 +327,7 @@ function allIncluded(outputTarget = 'email') {
332327
}
333328

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

337332
if (githubCache.fetching || (githubCache.cacheKey === cacheKey && githubCache.data)) {
338333
log('Fetch already in progress or data already fetched. Skipping fetch.');
@@ -404,19 +399,19 @@ function allIncluded(outputTarget = 'email') {
404399
log('Making public requests');
405400
}
406401

407-
// Build org part for query only if orgName is set and not empty
408-
console.log('[SCRUM-HELPER] orgName before API query:', orgName);
409-
console.log('[SCRUM-HELPER] orgName type:', typeof orgName);
410-
console.log('[SCRUM-HELPER] orgName length:', orgName ? orgName.length : 0);
411-
let orgPart = orgName && orgName.trim() ? `+org%3A${orgName}` : '';
412-
console.log('[SCRUM-HELPER] orgPart for API:', orgPart);
413-
console.log('[SCRUM-HELPER] orgPart length:', orgPart.length);
414-
let issueUrl = `https://api.github.com/search/issues?q=author%3A${githubUsername}${orgPart}+created%3A${startingDate}..${endingDate}&per_page=100`;
415-
let prUrl = `https://api.github.com/search/issues?q=commenter%3A${githubUsername}${orgPart}+updated%3A${startingDate}..${endingDate}&per_page=100`;
416-
console.log('[SCRUM-HELPER] issueUrl:', issueUrl);
417-
console.log('[SCRUM-HELPER] prUrl:', prUrl);
418-
let userUrl = `https://api.github.com/users/${githubUsername}`;
419-
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);
413+
let userUrl = `https://api.github.com/users/${githubUsername}`;
414+
420415
try {
421416
// throttling 500ms to avoid burst
422417
await new Promise(res => setTimeout(res, 500));
@@ -681,7 +676,6 @@ function allIncluded(outputTarget = 'email') {
681676
let content;
682677
if (lastWeekContribution == true || yesterdayContribution == true) {
683678
content = `<b>1. What did I do ${weekOrDay}?</b><br>
684-
685679
${lastWeekUl}<br>
686680
<b>2. What do I plan to do ${weekOrDay2}?</b><br>
687681
${nextWeekUl}<br>

0 commit comments

Comments
 (0)