fix: критические баги и качество кода — полный аудит
Критические фиксы: - main.py: монтировать /static из web/static/ (CSS не грузился совсем) - api/scans.py: filtered total count (был всегда общий, игнорируя фильтры) - web/routes.py: исправлен VALID_SORT_FIELDS (отсутствовали ключи packages) - web/routes.py: filtered total count для web scans list - package_detail.html: f.data.X вместо f.X (findings не отображались) Чистка мёртвого кода: - config.py: удалён _parse_repos и nexus_repositories (не использовались) - web/routes.py: удалён completed_scans/failed_scans (не отображались) - удалён мёртвый guarddog_nexus/static/style.css (67-байтный стаб) Качество кода: - web/routes.py: Jinja2 Environment кэшируется на уровне модуля - Вынесен дублирующийся JS в web/static/app.js - Вынесены дублирующиеся inline-стили в CSS-классы - Исправлен duplicate class attribute в списках - Удалены гигантские SVG из empty states Тесты: - 20 новых edge-case тестов (CSV export, search/filter/sort, 404, pagination) - Добавлен sample_flagged_scan fixture - Итого: 50 тестов, все зелёные
This commit is contained in:
@@ -36,18 +36,22 @@ async def list_scans(
|
||||
session: AsyncSession = Depends(get_session),
|
||||
):
|
||||
q = select(Scan)
|
||||
count_q = select(func.count(Scan.id))
|
||||
|
||||
if flagged is not None:
|
||||
q = q.where(Scan.flagged == flagged)
|
||||
count_q = count_q.where(Scan.flagged == flagged)
|
||||
if status:
|
||||
q = q.where(Scan.status == status)
|
||||
count_q = count_q.where(Scan.status == status)
|
||||
if repository:
|
||||
q = q.where(Scan.repository == repository)
|
||||
count_q = count_q.where(Scan.repository == repository)
|
||||
if search:
|
||||
pattern = f"%{search}%"
|
||||
q = q.where(
|
||||
Scan.package_name.ilike(pattern) | Scan.package_version.ilike(pattern)
|
||||
)
|
||||
condition = Scan.package_name.ilike(pattern) | Scan.package_version.ilike(pattern)
|
||||
q = q.where(condition)
|
||||
count_q = count_q.where(condition)
|
||||
|
||||
sort_field = VALID_SORT_FIELDS.get(sort_by, Scan.started_at)
|
||||
sort_dir = "asc" if sort_dir.lower() == "asc" else "desc"
|
||||
@@ -55,7 +59,7 @@ async def list_scans(
|
||||
|
||||
q = q.offset(offset).limit(limit)
|
||||
|
||||
total = await session.scalar(select(func.count(Scan.id)))
|
||||
total = await session.scalar(count_q)
|
||||
|
||||
scans = (await session.execute(q)).scalars().all()
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user