Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 300 // Keep closed issues from lingering in the roulette

export default async function Home() {
const issues = await fetchGithubIssues(process.env.GITHUB_TOKEN || "")
Expand Down
7 changes: 4 additions & 3 deletions components/IssueRoulette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import type { IssuesByFilter, Issue } from "@/lib/github"
import type { Issue, IssuesByFilter } from "@/lib/github"
import { format } from "date-fns"
import { AlertCircle, Calendar, Dices, ExternalLink, User } from "lucide-react"
import { useState } from "react"
Expand All @@ -32,8 +32,9 @@ export default function IssueRoulette({

try {
// Filter available issues based on bounty preference and used status
const availableIssues = initialIssues[filterType]
.filter((issue) => !usedIssues.has(issue.id))
const availableIssues = initialIssues[filterType].filter(
(issue) => !usedIssues.has(issue.id),
)

if (availableIssues.length === 0) {
setUsedIssues(new Set())
Expand Down
16 changes: 8 additions & 8 deletions lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Issue {
body: string
html_url: string
created_at: string
state: "open" | "closed"
user: {
login: string
avatar_url: string
Expand All @@ -32,7 +33,7 @@ export async function fetchGithubIssues(
org,
})

const reposNotArchived = repos.filter(repo => !repo.archived)
const reposNotArchived = repos.filter((repo) => !repo.archived)

// Fetch issues from all repositories; tolerate per-repo fetch failures
const allIssues = await Promise.allSettled(
Expand All @@ -52,10 +53,7 @@ export async function fetchGithubIssues(
},
}))
} catch (error) {
console.error(
`Failed to fetch issues for ${org}/${repo.name}:`,
error,
)
console.error(`Failed to fetch issues for ${org}/${repo.name}:`, error)
return []
}
}),
Expand All @@ -67,6 +65,7 @@ export async function fetchGithubIssues(
.filter(
(issue) =>
!issue.pull_request && // Not a PR
issue.state === "open" && // Still open if cached/revalidated late
!issue.assignees?.length, // Not assigned
)
.map((issue) => {
Expand All @@ -86,6 +85,7 @@ export async function fetchGithubIssues(
body: issue.body || "",
html_url: issue.html_url,
created_at: issue.created_at,
state: issue.state as "open" | "closed",
user: {
login: issue.user?.login || "unknown",
avatar_url: issue.user?.avatar_url || "",
Expand Down Expand Up @@ -133,9 +133,9 @@ export async function fetchGithubIssues(
}

return {
"bounty": getBountiedIssues(),
"all": getWeightedIssues(),
"unbountied": processedIssues
bounty: getBountiedIssues(),
all: getWeightedIssues(),
unbountied: processedIssues
.filter((issue) => (issue.bountyAmount ?? 0) === 0)
.slice(0, 20), // Keep same limit as other filters
}
Expand Down