generated from coulomb/repo-seed
perf(doi): 13x speedup for /repos/doi/summary (108s → ~6s)
Two fixes:
1. skip_consistency=True in summary mode — omits C7/C13 subprocess calls
(consistency_check.py) which were the main bottleneck (32 spawns for 16 repos).
Full check still available per-repo via GET /repos/{slug}/doi.
2. asyncio.gather — all repos evaluated in parallel instead of sequentially.
Also: rename Repositories page title from "Repos" to "Repositories".
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import uuid
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
@@ -80,8 +81,7 @@ async def doi_summary(session: AsyncSession = Depends(get_session)) -> list[DoIS
|
||||
domain_result = await session.execute(select(Domain))
|
||||
domain_map = {d.id: d.slug for d in domain_result.scalars().all()}
|
||||
|
||||
entries: list[DoISummaryEntry] = []
|
||||
for repo in repos:
|
||||
async def _check_one(repo: ManagedRepo) -> DoISummaryEntry:
|
||||
repo_dict = {
|
||||
"slug": repo.slug,
|
||||
"domain_slug": domain_map.get(repo.domain_id),
|
||||
@@ -90,8 +90,10 @@ async def doi_summary(session: AsyncSession = Depends(get_session)) -> list[DoIS
|
||||
"host_paths": repo.host_paths or {},
|
||||
"last_sbom_at": str(repo.last_sbom_at) if repo.last_sbom_at else None,
|
||||
}
|
||||
report = await _doi_evaluate(repo_dict)
|
||||
entries.append(DoISummaryEntry(
|
||||
# skip_consistency=True: omits C7/C13 subprocess calls for speed.
|
||||
# The full check is available via GET /repos/{slug}/doi.
|
||||
report = await _doi_evaluate(repo_dict, skip_consistency=True)
|
||||
return DoISummaryEntry(
|
||||
repo_slug=repo.slug,
|
||||
domain_slug=domain_map.get(repo.domain_id),
|
||||
tier=report.tier,
|
||||
@@ -99,7 +101,9 @@ async def doi_summary(session: AsyncSession = Depends(get_session)) -> list[DoIS
|
||||
standard_pass=report.standard_pass,
|
||||
full_pass=report.full_pass,
|
||||
checked_at=report.checked_at,
|
||||
))
|
||||
)
|
||||
|
||||
entries: list[DoISummaryEntry] = list(await asyncio.gather(*[_check_one(r) for r in repos]))
|
||||
|
||||
tier_order = {"none": 0, "core": 1, "standard": 2, "full": 3}
|
||||
entries.sort(key=lambda e: tier_order.get(e.tier, 0))
|
||||
|
||||
Reference in New Issue
Block a user