fix: show all repos in git widget, remove artificial slice(8) limit
All checks were successful
Build & Deploy Dashboard / deploy (push) Successful in 1m0s
All checks were successful
Build & Deploy Dashboard / deploy (push) Successful in 1m0s
This commit is contained in:
@@ -6,21 +6,15 @@ const GITEA_TOKEN = "f7a12c4f58e0799ac119243d0d95f4551c5be8b1";
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
// Получить репозитории
|
|
||||||
const reposRes = await fetch(
|
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) }
|
{ signal: AbortSignal.timeout(8000) }
|
||||||
);
|
);
|
||||||
const reposData = await reposRes.json();
|
const reposData = await reposRes.json();
|
||||||
const repos = reposData.data || [];
|
const repos = (reposData.data || []).filter((r: any) => !r.archived && !r.empty);
|
||||||
|
|
||||||
// Получить последние коммиты из топ-5 активных репо
|
|
||||||
const topRepos = repos
|
|
||||||
.filter((r: any) => !r.archived && !r.empty)
|
|
||||||
.slice(0, 8);
|
|
||||||
|
|
||||||
const commits = await Promise.allSettled(
|
const commits = await Promise.allSettled(
|
||||||
topRepos.map(async (repo: any) => {
|
repos.map(async (repo: any) => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${GITEA_URL}/api/v1/repos/${repo.full_name}/commits?limit=3&token=${GITEA_TOKEN}`,
|
`${GITEA_URL}/api/v1/repos/${repo.full_name}/commits?limit=3&token=${GITEA_TOKEN}`,
|
||||||
{ signal: AbortSignal.timeout(5000) }
|
{ signal: AbortSignal.timeout(5000) }
|
||||||
@@ -43,8 +37,7 @@ export async function GET() {
|
|||||||
const result = commits
|
const result = commits
|
||||||
.filter(r => r.status === "fulfilled" && (r.value as any).commits.length > 0)
|
.filter(r => r.status === "fulfilled" && (r.value as any).commits.length > 0)
|
||||||
.map(r => (r as any).value)
|
.map(r => (r as any).value)
|
||||||
.sort((a: any, b: any) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime())
|
.sort((a: any, b: any) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
|
||||||
.slice(0, 6);
|
|
||||||
|
|
||||||
return NextResponse.json({ repos: result });
|
return NextResponse.json({ repos: result });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user