From a40e85b3992afcea90c2898f399c8719c72fab10 Mon Sep 17 00:00:00 2001 From: petrCher <88943157+petrCher@users.noreply.github.com> Date: Sat, 27 Sep 2025 15:16:28 +0300 Subject: [PATCH] minor fixes --- Makefile | 2 +- rating_api/models/db.py | 3 --- rating_api/routes/lecturer.py | 7 +++---- rating_api/schemas/models.py | 6 ++++++ tests/test_routes/test_lecturer.py | 3 --- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fe8b677..a5b1c79 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,4 @@ db: docker run -d -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust --name db-rating_api postgres:15 migrate: - alembic upgrade head + source ./venv/bin/activate && alembic upgrade head diff --git a/rating_api/models/db.py b/rating_api/models/db.py index 18dae0b..d7adcd1 100644 --- a/rating_api/models/db.py +++ b/rating_api/models/db.py @@ -5,7 +5,6 @@ import uuid from enum import Enum -from fastapi_sqlalchemy import db from sqlalchemy import ( UUID, Boolean, @@ -29,8 +28,6 @@ from sqlalchemy.orm import Mapped, mapped_column, relationship from sqlalchemy.orm.attributes import InstrumentedAttribute -from rating_api.utils.mark import calc_weighted_mark - from .base import BaseDbModel diff --git a/rating_api/routes/lecturer.py b/rating_api/routes/lecturer.py index d420400..2175cb9 100644 --- a/rating_api/routes/lecturer.py +++ b/rating_api/routes/lecturer.py @@ -21,7 +21,6 @@ LecturerUpdateRatingPatch, LecturerWithRank, ) -from rating_api.utils.mark import calc_weighted_mark lecturer = APIRouter(prefix="/lecturer", tags=["Lecturer"]) @@ -53,7 +52,7 @@ async def update_lecturer_rating( _=Depends(UnionAuth(scopes=["rating.lecturer.update_rating"], allow_none=False, auto_error=True)), ) -> LecturerUpdateRatingPatch: """ - Scopes: `["rating.lecturer.impor_rating"]` + Scopes: `["rating.lecturer.update_rating"]` Обновляет рейтинг преподавателя в базе данных RatingAPI """ @@ -72,7 +71,7 @@ async def update_lecturer_rating( success_fl = False lecturer_rank_dumped = lecturer_rank.model_dump() - lecturer_rank_dumped["update_ts"] = datetime.datetime.now(tz=datetime.timezone.utc) + lecturer_rank_dumped["rank_update_ts"] = datetime.datetime.now(tz=datetime.timezone.utc) lecturer_id = lecturer_rank_dumped.pop("id") @@ -87,7 +86,7 @@ async def update_lecturer_rating( else: response["failed"] += 1 response["failed_id"].append(lecturer_id) - response_validated = LecturerUpdateRatingPatch.model_validate(**response) + response_validated = LecturerUpdateRatingPatch.model_validate(response) return response_validated diff --git a/rating_api/schemas/models.py b/rating_api/schemas/models.py index dfced18..ad1b0a0 100644 --- a/rating_api/schemas/models.py +++ b/rating_api/schemas/models.py @@ -76,10 +76,16 @@ class CommentGetAll(Base): class CommentGetAllWithStatus(Base): comments: list[CommentGetWithStatus] = [] + limit: int + offset: int + total: int class CommentGetAllWithAllInfo(Base): comments: list[CommentGetWithAllInfo] = [] + limit: int + offset: int + total: int class LecturerUserCommentPost(Base): diff --git a/tests/test_routes/test_lecturer.py b/tests/test_routes/test_lecturer.py index 6408c85..3d4beed 100644 --- a/tests/test_routes/test_lecturer.py +++ b/tests/test_routes/test_lecturer.py @@ -1,6 +1,4 @@ -import datetime import logging -from unittest.mock import patch import pytest from fastapi_sqlalchemy import db @@ -9,7 +7,6 @@ from rating_api.models import Comment, Lecturer, ReviewStatus from rating_api.settings import get_settings -from rating_api.utils.mark import calc_weighted_mark logger = logging.getLogger(__name__)