From f55ab79587d0719b8d8b9f94e802f7d5f07c8c76 Mon Sep 17 00:00:00 2001 From: zugdev Date: Sun, 8 Dec 2024 12:13:48 -0300 Subject: [PATCH] feat: only show priority label --- src/home/fetch-github/fetch-data.ts | 2 +- src/home/rendering/render-github-issues.ts | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/home/fetch-github/fetch-data.ts b/src/home/fetch-github/fetch-data.ts index 2961281..43ce8e1 100644 --- a/src/home/fetch-github/fetch-data.ts +++ b/src/home/fetch-github/fetch-data.ts @@ -94,7 +94,7 @@ async function fetchIssueFromPullRequest(pullRequest: GitHubPullRequest): Promis if (issueUrlMatch) { // Full URL to the issue is provided - const [,, owner, repo, issueNumber] = issueUrlMatch; + const [, , owner, repo, issueNumber] = issueUrlMatch; apiUrl = `https://api.github.com/repos/${owner}/${repo}/issues/${issueNumber}`; } else if (issueNumberMatch) { // Only issue number is provided, construct API URL using current repo info diff --git a/src/home/rendering/render-github-issues.ts b/src/home/rendering/render-github-issues.ts index 97bacff..0ab085d 100644 --- a/src/home/rendering/render-github-issues.ts +++ b/src/home/rendering/render-github-issues.ts @@ -113,17 +113,16 @@ function setUpIssueElement( } function parseAndGenerateLabels(notification: GitHubIssue) { - type LabelKey = "Price: " | "Time: " | "Priority: "; + type LabelKey = "Priority: "; - const labelOrder: Record = { "Price: ": 1, "Time: ": 2, "Priority: ": 3 }; + const labelOrder: Record = { "Priority: ": 1 }; - const { labels, otherLabels } = notification.labels.reduce( + const { labels } = notification.labels.reduce( (acc, label) => { // check if label is a single string if (typeof label === "string") { return { labels: [], - otherLabels: [], }; } @@ -131,32 +130,23 @@ function parseAndGenerateLabels(notification: GitHubIssue) { if (!label.name) { return { labels: [], - otherLabels: [], }; } - const match = label.name.match(/^(Price|Time|Priority): /); + const match = label.name.match(/^(Priority): /); if (match) { const name = label.name.replace(match[0], ""); const labelStr = ``; acc.labels.push({ order: labelOrder[match[0] as LabelKey], label: labelStr }); - } else if (!label.name.startsWith("Partner: ") && !label.name.startsWith("id: ") && !label.name.startsWith("Unavailable")) { - acc.otherLabels.push(label.name); } return acc; }, - { labels: [] as { order: number; label: string }[], otherLabels: [] as string[] } + { labels: [] as { order: number; label: string }[] } ); // Sort labels labels.sort((a: { order: number }, b: { order: number }) => a.order - b.order); - // Log the other labels - if (otherLabels.length) { - const otherLabelName = otherLabels.shift() as string; - labels.unshift({ order: 0, label: `` }); - } - return labels.map((label) => label.label); }