From fbbeaa24a20c574db6371153446fb5aacc8198ed Mon Sep 17 00:00:00 2001 From: ak10082247-max Date: Mon, 15 Jun 2026 14:17:27 +0100 Subject: [PATCH 1/2] Fixes #10: update bounty extraction and cache interval --- app/page.tsx | 2 +- lib/github.ts | 52 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 9f82421..c46e6e6 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -5,7 +5,7 @@ import { fetchGithubIssues } from "@/lib/github" import { GitHubLogoIcon } from "@radix-ui/react-icons" import { Suspense } from "react" -export const revalidate = 3600 // Revalidate every hour +export const revalidate = 600 // Revalidate every 10 minutes export default async function Home() { const issues = await fetchGithubIssues(process.env.GITHUB_TOKEN || "") diff --git a/lib/github.ts b/lib/github.ts index 58553c5..4d13820 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -62,22 +62,63 @@ export async function fetchGithubIssues( ) // Flatten and filter issues - const processedIssues = allIssues + const openIssues = allIssues .flatMap((result) => (result.status === "fulfilled" ? result.value : [])) .filter( (issue) => !issue.pull_request && // Not a PR !issue.assignees?.length, // Not assigned ) - .map((issue) => { + + const processedIssues = await Promise.all( + openIssues.map(async (issue) => { // Check for bounty label and parse amount const hasBountyLabel = issue.labels?.some( - (label: any) => label.name === "💎 Bounty", + (label: any) => label.name === "💎 Bounty" || label.name.toLowerCase().includes("bounty"), ) + let bountyAmount = 0 - if (hasBountyLabel) { + + // 1. Try to extract from labels like "$50" + if (issue.labels) { + for (const label of issue.labels) { + const match = label.name.match(/\$(\d+)/) + if (match) { + bountyAmount = parseInt(match[1], 10) + break + } + } + } + + // 2. Try to extract from issue body + if (bountyAmount === 0 && hasBountyLabel) { const bountyMatch = (issue.body || "").match(/\/bounty\s*\$(\d+)/i) - bountyAmount = bountyMatch ? parseInt(bountyMatch[1], 10) : 0 + if (bountyMatch) { + bountyAmount = parseInt(bountyMatch[1], 10) + } + } + + // 3. Try to extract from Algora bot comments + if (bountyAmount === 0 && hasBountyLabel && issue.number) { + try { + const comments = await octokit.paginate(octokit.issues.listComments, { + owner: org, + repo: issue.repository.name, + issue_number: issue.number, + }) + + for (const comment of comments) { + if (comment.user?.login === "algora-bot" || comment.body?.includes("bounty")) { + const match = (comment.body || "").match(/\$(\d+)/) + if (match) { + bountyAmount = parseInt(match[1], 10) + break + } + } + } + } catch (e) { + console.error(`Failed to fetch comments for ${issue.repository.full_name}#${issue.number}`, e) + } } return { @@ -94,6 +135,7 @@ export async function fetchGithubIssues( bountyAmount, } }) + ) // Calculate dates for weighting const now = new Date() From 61c0a1935406e65504604d45acdef369585854b1 Mon Sep 17 00:00:00 2001 From: ak10082247-max Date: Mon, 15 Jun 2026 14:18:15 +0100 Subject: [PATCH 2/2] Fixes #10: update bounty extraction and cache interval --- lib/github.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/github.ts b/lib/github.ts index 4d13820..c4d8ba9 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -74,7 +74,10 @@ export async function fetchGithubIssues( openIssues.map(async (issue) => { // Check for bounty label and parse amount const hasBountyLabel = issue.labels?.some( - (label: any) => label.name === "💎 Bounty" || label.name.toLowerCase().includes("bounty"), + (label: any) => { + const name = typeof label === 'string' ? label : label.name; + return name === "💎 Bounty" || (name && name.toLowerCase().includes("bounty")); + } ) let bountyAmount = 0 @@ -82,10 +85,13 @@ export async function fetchGithubIssues( // 1. Try to extract from labels like "$50" if (issue.labels) { for (const label of issue.labels) { - const match = label.name.match(/\$(\d+)/) - if (match) { - bountyAmount = parseInt(match[1], 10) - break + const labelName = typeof label === 'string' ? label : label.name; + if (labelName) { + const match = labelName.match(/\$(\d+)/) + if (match) { + bountyAmount = parseInt(match[1], 10) + break + } } } }