reaction-model-fix
All checks were successful
deploy / deploy (push) Successful in 2m19s

This commit is contained in:
Untone 2023-11-27 19:03:47 +03:00
parent 909ddbd79d
commit caa2dbfdf3
6 changed files with 83 additions and 77 deletions

View File

@ -1,3 +1,6 @@
[0.2.16]
- schema: Reaction.range -> Reaction.quote
[0.2.15]
- schema: Shout.created_by removed
- schema: Shout.mainTopic removed

View File

@ -7,21 +7,23 @@ from services.db import Base
class ReactionKind(Enumeration):
# TYPE = <reaction index> # rating diff
# editor mode
AGREE = 1 # +1
DISAGREE = 2 # -1
PROOF = 3 # +1
DISPROOF = 4 # -1
ASK = 5 # +0
PROPOSE = 6 # +0
QUOTE = 7 # +0 bookmark
COMMENT = 8 # +0
ACCEPT = 9 # +1
REJECT = 0 # -1
ASK = 3 # +0
PROPOSE = 4 # +0
PROOF = 5 # +1
DISPROOF = 6 # -1
ACCEPT = 7 # +1
REJECT = 8 # -1
# public feed
QUOTE = 9 # +0 bookmark
COMMENT = 0 # +0
LIKE = 11 # +1
DISLIKE = 12 # -1
REMARK = 13 # 0
FOOTNOTE = 14 # 0
# TYPE = <reaction index> # rating diff
class Reaction(Base):
@ -35,7 +37,7 @@ class Reaction(Base):
deleted_by = Column(ForeignKey("author.id"), nullable=True, index=True)
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
range = Column(String, nullable=True, comment="<start index>:<end>")
quote = Column(String, nullable=True, comment="Original quoted text")
kind = Column(Enum(ReactionKind), nullable=False)
oid = Column(String)

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "discoursio-core"
version = "0.2.15"
version = "0.2.16"
description = "core module for discours.io"
authors = ["discoursio devteam"]
license = "MIT"

View File

@ -138,14 +138,14 @@ async def get_authors_all(_, _info):
@query.field("getAuthor")
async def get_author(_, _info, slug="", user=None, author=None):
if slug or user or author:
async def get_author(_, _info, slug="", user=None, author_id=None):
if slug or user or author_id:
if slug:
q = select(Author).where(Author.slug == slug)
elif user:
q = select(Author).where(Author.user == user)
elif author:
q = select(Author).where(Author.id == author)
elif author_id:
q = select(Author).where(Author.id == author_id)
q = add_author_stat_columns(q)
authors = get_authors_from_query(q)

View File

@ -163,6 +163,7 @@ async def create_reaction(_, info, reaction):
with local_session() as session:
shout = session.query(Shout).where(Shout.id == reaction["shout"]).one()
author = session.query(Author).where(Author.user == user_id).first()
if shout and author:
reaction["created_by"] = author.id
if reaction["kind"] in [ReactionKind.DISLIKE.name, ReactionKind.LIKE.name]:
existing_reaction = (

View File

@ -210,7 +210,7 @@ input TopicInput {
input ReactionInput {
kind: ReactionKind!
shout: Int!
range: String
quote: String
body: String
reply_to: Int
}