Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions rating_api/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import uuid
from enum import Enum

from fastapi_sqlalchemy import db
from sqlalchemy import (
UUID,
Boolean,
Expand All @@ -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


Expand Down
7 changes: 3 additions & 4 deletions rating_api/routes/lecturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
LecturerUpdateRatingPatch,
LecturerWithRank,
)
from rating_api.utils.mark import calc_weighted_mark


lecturer = APIRouter(prefix="/lecturer", tags=["Lecturer"])
Expand Down Expand Up @@ -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
"""
Expand All @@ -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")

Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions rating_api/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_routes/test_lecturer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import datetime
import logging
from unittest.mock import patch

import pytest
from fastapi_sqlalchemy import db
Expand All @@ -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__)
Expand Down