From ece918ac2c46802edcb69f2423bceffb5c4a9afb Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 29 Nov 2023 23:22:39 +0300 Subject: [PATCH] plus-fix --- orm/author.py | 2 +- pyproject.toml | 3 ++- resolvers/author.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/orm/author.py b/orm/author.py index 649a7d04..ba9fcc52 100644 --- a/orm/author.py +++ b/orm/author.py @@ -13,7 +13,7 @@ class AuthorRating(Base): id = None # type: ignore rater = Column(ForeignKey("author.id"), primary_key=True, index=True) author = Column(ForeignKey("author.id"), primary_key=True, index=True) - value = Column(Integer) + plus = Column(Boolean) class AuthorFollower(Base): diff --git a/pyproject.toml b/pyproject.toml index e76e3d9a..e47c7c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ SQLAlchemy = "^2.0.22" psycopg2-binary = "^2.9.9" redis = {extras = ["hiredis"], version = "^5.0.1"} uvicorn = "^0.24" -sentry-sdk = "^1.32.0" +sentry-sdk = "^1.38.0" starlette = "^0.32.0.post1" gql = "^3.4.1" ariadne = "^0.21" @@ -29,6 +29,7 @@ build-backend = "poetry.core.masonry.api" pytest = "^7.4.2" black = { version = "^23.9.1", python = ">=3.12" } ruff = { version = "^0.1.0", python = ">=3.12" } +setuptools = "^69.0.2" [tool.black] line-length = 120 diff --git a/resolvers/author.py b/resolvers/author.py index 82d7bcb2..33508bfe 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -227,14 +227,14 @@ async def rate_author(_, info, rated_slug, value): .filter(and_(AuthorRating.rater == rater.id, AuthorRating.author == rated_author.id)) .first() ) - if rating: - rating.value = value + if value > 0: + rating.plus = True session.add(rating) session.commit() return {} else: try: - rating = AuthorRating(rater=rater.id, author=rated_author.id, value=value) + rating = AuthorRating(rater=rater.id, author=rated_author.id, plus=value > 0) session.add(rating) session.commit() except Exception as err: