fix: show all repos in git widget, remove artificial slice(8) limit
All checks were successful
Build & Deploy Dashboard / deploy (push) Successful in 1m0s

This commit is contained in:
Cosmo
2026-04-16 15:51:11 +00:00
parent 60a6215ad3
commit 9b39deba7e

View File

@@ -6,21 +6,15 @@ const GITEA_TOKEN = "f7a12c4f58e0799ac119243d0d95f4551c5be8b1";
export async function GET() {
try {
// Получить репозитории
const reposRes = await fetch(
`${GITEA_URL}/api/v1/repos/search?limit=20&sort=updated&token=${GITEA_TOKEN}`,
`${GITEA_URL}/api/v1/repos/search?limit=50&sort=updated&token=${GITEA_TOKEN}`,
{ signal: AbortSignal.timeout(8000) }
);
const reposData = await reposRes.json();
const repos = reposData.data || [];
// Получить последние коммиты из топ-5 активных репо
const topRepos = repos
.filter((r: any) => !r.archived && !r.empty)
.slice(0, 8);
const repos = (reposData.data || []).filter((r: any) => !r.archived && !r.empty);
const commits = await Promise.allSettled(
topRepos.map(async (repo: any) => {
repos.map(async (repo: any) => {
const res = await fetch(
`${GITEA_URL}/api/v1/repos/${repo.full_name}/commits?limit=3&token=${GITEA_TOKEN}`,
{ signal: AbortSignal.timeout(5000) }
@@ -43,8 +37,7 @@ export async function GET() {
const result = commits
.filter(r => r.status === "fulfilled" && (r.value as any).commits.length > 0)
.map(r => (r as any).value)
.sort((a: any, b: any) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime())
.slice(0, 6);
.sort((a: any, b: any) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
return NextResponse.json({ repos: result });
} catch (e) {