plus-fix
This commit is contained in:
parent
a0ee3a1be9
commit
ece918ac2c
|
@ -13,7 +13,7 @@ class AuthorRating(Base):
|
||||||
id = None # type: ignore
|
id = None # type: ignore
|
||||||
rater = Column(ForeignKey("author.id"), primary_key=True, index=True)
|
rater = Column(ForeignKey("author.id"), primary_key=True, index=True)
|
||||||
author = 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):
|
class AuthorFollower(Base):
|
||||||
|
|
|
@ -12,7 +12,7 @@ SQLAlchemy = "^2.0.22"
|
||||||
psycopg2-binary = "^2.9.9"
|
psycopg2-binary = "^2.9.9"
|
||||||
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
||||||
uvicorn = "^0.24"
|
uvicorn = "^0.24"
|
||||||
sentry-sdk = "^1.32.0"
|
sentry-sdk = "^1.38.0"
|
||||||
starlette = "^0.32.0.post1"
|
starlette = "^0.32.0.post1"
|
||||||
gql = "^3.4.1"
|
gql = "^3.4.1"
|
||||||
ariadne = "^0.21"
|
ariadne = "^0.21"
|
||||||
|
@ -29,6 +29,7 @@ build-backend = "poetry.core.masonry.api"
|
||||||
pytest = "^7.4.2"
|
pytest = "^7.4.2"
|
||||||
black = { version = "^23.9.1", python = ">=3.12" }
|
black = { version = "^23.9.1", python = ">=3.12" }
|
||||||
ruff = { version = "^0.1.0", python = ">=3.12" }
|
ruff = { version = "^0.1.0", python = ">=3.12" }
|
||||||
|
setuptools = "^69.0.2"
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 120
|
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))
|
.filter(and_(AuthorRating.rater == rater.id, AuthorRating.author == rated_author.id))
|
||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
if rating:
|
if value > 0:
|
||||||
rating.value = value
|
rating.plus = True
|
||||||
session.add(rating)
|
session.add(rating)
|
||||||
session.commit()
|
session.commit()
|
||||||
return {}
|
return {}
|
||||||
else:
|
else:
|
||||||
try:
|
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.add(rating)
|
||||||
session.commit()
|
session.commit()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user