From 9db3801438e673f4531c9df74f7d5d61e202271f Mon Sep 17 00:00:00 2001 From: zugdev Date: Thu, 9 Jan 2025 15:52:43 -0300 Subject: [PATCH] feat: add more precise logger --- src/home/fetch-github/fetch-data.ts | 25 +++++++++++++------ .../rendering/render-github-notifications.ts | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/home/fetch-github/fetch-data.ts b/src/home/fetch-github/fetch-data.ts index 397a8ce..f10693a 100644 --- a/src/home/fetch-github/fetch-data.ts +++ b/src/home/fetch-github/fetch-data.ts @@ -20,7 +20,7 @@ async function fetchNotifications(): Promise { if (error instanceof RequestError && error.status === 403) { await handleRateLimit(octokit, error); } - console.warn("Error fetching notifications:", error); + console.warn("error fetching notifications:", error); } return null; } @@ -46,11 +46,16 @@ function preFilterNotifications(devpoolRepos: Set, notifications: GitHub notification.reason ) ) { + console.log("skipping ", notification.subject.title, "cause of reason", notification.reason); return false; } // Ignore notifications from repos that are not in devpoolRepos const repoName = notification.repository.full_name; + if (!devpoolRepos.has(repoName)) { + console.log("skipping ", notification.subject.title, "cause of repo", repoName); + return false; + } return devpoolRepos.has(repoName); }); } @@ -113,20 +118,19 @@ export async function getPullRequestNotifications( const pullRequestUrl = notification.subject.url; const pullRequest = pullRequests.find((pr) => pr.url === pullRequestUrl); if (!pullRequest || pullRequest.draft || pullRequest.state === "closed") { - console.log("Pull request is draft or closed", pullRequest); + console.log("skipping ", notification.subject.title, "cause draft or closed"); continue; // Skip draft or closed pull requests } const issue = await fetchIssueFromPullRequest(pullRequest, issues); if (!issue) { - console.log("No associated issue", pullRequest); + console.log("skipping ", notification.subject.title, "cause no associated issue"); continue; // Skip if no associated issue } aggregatedData.push({ notification, pullRequest, issue, backlinkCount: 0 }); } - console.log("pullRequestNotifications", aggregatedData); return aggregatedData; } @@ -141,14 +145,13 @@ export function getIssueNotifications(devpoolRepos: Set, notifications: const issueUrl = notification.subject.url; const issue = issues.find((issue) => issue.url === issueUrl); if (!issue || issue.state === "closed") { - console.log("Issue is closed", issue); + console.log("skipping ", notification.subject.title, "cause issue is closed"); continue; // Skip closed issues } aggregatedData.push({ notification, pullRequest: null, issue, backlinkCount: 0 }); } - console.log("issueNotifications", aggregatedData); return aggregatedData; } @@ -248,22 +251,28 @@ export async function fetchAllNotifications(): Promise { if (!aggregated.issue || !aggregated.issue.labels) { + // skip if no issue or labels + console.log("skipping ", aggregated.notification.subject.title, "cause no labels or issue"); return false; } - return aggregated.issue.labels.some((label) => { + const isSuccess = aggregated.issue.labels.some((label) => { if (typeof label === "string" || !label.name) { return false; } const match = label.name.match(/^(Priority): /); if (match) { - console.log("issue", aggregated.issue.title, "label", label); return true; } return false; }); + + if (!isSuccess){ + console.log("skipping ", aggregated.notification.subject.title, "cause no priority label"); + } + return isSuccess; }); for (const aggregated of filteredNotifications) { diff --git a/src/home/rendering/render-github-notifications.ts b/src/home/rendering/render-github-notifications.ts index fc916a5..25636dd 100644 --- a/src/home/rendering/render-github-notifications.ts +++ b/src/home/rendering/render-github-notifications.ts @@ -116,6 +116,7 @@ function setUpIssueElement( commentData: { userType: string, url: string; avatarUrl: string; commentBody: string } ) { if(commentData.userType === "Bot" && !showBotNotifications) { + console.log("bot notifications are hidden"); issueElement.style.display = "none"; }