feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile
- Добавлена колонка 'Тип' во все таблицы истории сборок - Для push операций отображается registry вместо платформ - Сохранение пользователя при создании push лога - Исправлена ошибка с logger в push_docker_image endpoint - Улучшено отображение истории сборок с визуальными индикаторами
This commit is contained in:
69
app/api/v1/endpoints/stats.py
Normal file
69
app/api/v1/endpoints/stats.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""
|
||||
API endpoints для статистики
|
||||
Автор: Сергей Антропов
|
||||
Сайт: https://devops.org.ru
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import HTMLResponse
|
||||
from pathlib import Path
|
||||
from app.core.config import settings
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/")
|
||||
async def get_stats():
|
||||
"""Общая статистика"""
|
||||
roles_dir = settings.PROJECT_ROOT / "roles"
|
||||
roles_count = 0
|
||||
if roles_dir.exists():
|
||||
roles = [d for d in roles_dir.iterdir()
|
||||
if d.is_dir() and d.name != "deploy.yml"]
|
||||
roles_count = len(roles)
|
||||
|
||||
return {
|
||||
"roles": roles_count,
|
||||
"tests": 0, # TODO: из БД
|
||||
"success": 0, # TODO: из БД
|
||||
"docker": 0 # TODO: из Docker API
|
||||
}
|
||||
|
||||
|
||||
@router.get("/roles", response_class=HTMLResponse)
|
||||
async def get_roles_count():
|
||||
"""Количество ролей"""
|
||||
try:
|
||||
roles_dir = settings.PROJECT_ROOT / "roles"
|
||||
if not roles_dir.exists():
|
||||
return "0"
|
||||
|
||||
# Подсчет ролей (исключая deploy.yml)
|
||||
roles = [d for d in roles_dir.iterdir()
|
||||
if d.is_dir() and d.name != "deploy.yml" and not d.name.startswith(".")]
|
||||
|
||||
return str(len(roles))
|
||||
except Exception as e:
|
||||
# В случае ошибки возвращаем 0
|
||||
return "0"
|
||||
|
||||
|
||||
@router.get("/tests", response_class=HTMLResponse)
|
||||
async def get_tests_count():
|
||||
"""Количество тестов"""
|
||||
# TODO: Реализовать через БД
|
||||
return "0"
|
||||
|
||||
|
||||
@router.get("/success", response_class=HTMLResponse)
|
||||
async def get_success_count():
|
||||
"""Количество успешных тестов"""
|
||||
# TODO: Реализовать через БД
|
||||
return "0"
|
||||
|
||||
|
||||
@router.get("/docker", response_class=HTMLResponse)
|
||||
async def get_docker_count():
|
||||
"""Количество Docker образов"""
|
||||
# TODO: Реализовать через Docker API
|
||||
return "0"
|
||||
Reference in New Issue
Block a user