refresh api and tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Роуты для просмотра автомобилей и агрегированной статистики.
|
||||
# Роуты для авто и статистики.
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy import func, select
|
||||
@@ -22,7 +22,7 @@ def list_cars(
|
||||
is_sold: bool | None = None,
|
||||
persistence: PersistenceService = Depends(get_persistence),
|
||||
):
|
||||
# Список автомобилей с пагинацией и фильтрами
|
||||
# Список авто с фильтрами.
|
||||
with persistence.session_scope() as session:
|
||||
query = select(Car)
|
||||
|
||||
@@ -59,7 +59,7 @@ def get_car(
|
||||
car_id: int,
|
||||
persistence: PersistenceService = Depends(get_persistence),
|
||||
):
|
||||
# Детальная информация об автомобиле с изображениями
|
||||
# Карточка авто с фото.
|
||||
with persistence.session_scope() as session:
|
||||
car = session.get(Car, car_id)
|
||||
if car is None:
|
||||
@@ -72,7 +72,7 @@ def get_car_by_origin(
|
||||
origin_id: str,
|
||||
persistence: PersistenceService = Depends(get_persistence),
|
||||
):
|
||||
# Поиск автомобиля по origin_id
|
||||
# Поиск по origin_id.
|
||||
with persistence.session_scope() as session:
|
||||
car = session.execute(
|
||||
select(Car).where(Car.origin_id == origin_id)
|
||||
@@ -84,7 +84,7 @@ def get_car_by_origin(
|
||||
|
||||
@router.get("/stats")
|
||||
def get_stats(persistence: PersistenceService = Depends(get_persistence)):
|
||||
# Общая статистика по БД
|
||||
# Общая статистика.
|
||||
with persistence.session_scope() as session:
|
||||
total_cars = session.execute(select(func.count(Car.id))).scalar() or 0
|
||||
total_images = session.execute(select(func.count(Image.id))).scalar() or 0
|
||||
|
||||
Reference in New Issue
Block a user