plus-fix
This commit is contained in:
parent
a0ee3a1be9
commit
ece918ac2c
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user