This commit is contained in:
parent
909ddbd79d
commit
caa2dbfdf3
|
@ -1,3 +1,6 @@
|
||||||
|
[0.2.16]
|
||||||
|
- schema: Reaction.range -> Reaction.quote
|
||||||
|
|
||||||
[0.2.15]
|
[0.2.15]
|
||||||
- schema: Shout.created_by removed
|
- schema: Shout.created_by removed
|
||||||
- schema: Shout.mainTopic removed
|
- schema: Shout.mainTopic removed
|
||||||
|
|
|
@ -7,21 +7,23 @@ from services.db import Base
|
||||||
|
|
||||||
|
|
||||||
class ReactionKind(Enumeration):
|
class ReactionKind(Enumeration):
|
||||||
|
# TYPE = <reaction index> # rating diff
|
||||||
|
|
||||||
|
# editor mode
|
||||||
AGREE = 1 # +1
|
AGREE = 1 # +1
|
||||||
DISAGREE = 2 # -1
|
DISAGREE = 2 # -1
|
||||||
PROOF = 3 # +1
|
ASK = 3 # +0
|
||||||
DISPROOF = 4 # -1
|
PROPOSE = 4 # +0
|
||||||
ASK = 5 # +0
|
PROOF = 5 # +1
|
||||||
PROPOSE = 6 # +0
|
DISPROOF = 6 # -1
|
||||||
QUOTE = 7 # +0 bookmark
|
ACCEPT = 7 # +1
|
||||||
COMMENT = 8 # +0
|
REJECT = 8 # -1
|
||||||
ACCEPT = 9 # +1
|
|
||||||
REJECT = 0 # -1
|
# public feed
|
||||||
|
QUOTE = 9 # +0 bookmark
|
||||||
|
COMMENT = 0 # +0
|
||||||
LIKE = 11 # +1
|
LIKE = 11 # +1
|
||||||
DISLIKE = 12 # -1
|
DISLIKE = 12 # -1
|
||||||
REMARK = 13 # 0
|
|
||||||
FOOTNOTE = 14 # 0
|
|
||||||
# TYPE = <reaction index> # rating diff
|
|
||||||
|
|
||||||
|
|
||||||
class Reaction(Base):
|
class Reaction(Base):
|
||||||
|
@ -35,7 +37,7 @@ class Reaction(Base):
|
||||||
deleted_by = Column(ForeignKey("author.id"), nullable=True, index=True)
|
deleted_by = Column(ForeignKey("author.id"), nullable=True, index=True)
|
||||||
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
||||||
reply_to = Column(ForeignKey("reaction.id"), nullable=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)
|
kind = Column(Enum(ReactionKind), nullable=False)
|
||||||
|
|
||||||
oid = Column(String)
|
oid = Column(String)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "discoursio-core"
|
name = "discoursio-core"
|
||||||
version = "0.2.15"
|
version = "0.2.16"
|
||||||
description = "core module for discours.io"
|
description = "core module for discours.io"
|
||||||
authors = ["discoursio devteam"]
|
authors = ["discoursio devteam"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -138,14 +138,14 @@ async def get_authors_all(_, _info):
|
||||||
|
|
||||||
|
|
||||||
@query.field("getAuthor")
|
@query.field("getAuthor")
|
||||||
async def get_author(_, _info, slug="", user=None, author=None):
|
async def get_author(_, _info, slug="", user=None, author_id=None):
|
||||||
if slug or user or author:
|
if slug or user or author_id:
|
||||||
if slug:
|
if slug:
|
||||||
q = select(Author).where(Author.slug == slug)
|
q = select(Author).where(Author.slug == slug)
|
||||||
elif user:
|
elif user:
|
||||||
q = select(Author).where(Author.user == user)
|
q = select(Author).where(Author.user == user)
|
||||||
elif author:
|
elif author_id:
|
||||||
q = select(Author).where(Author.id == author)
|
q = select(Author).where(Author.id == author_id)
|
||||||
q = add_author_stat_columns(q)
|
q = add_author_stat_columns(q)
|
||||||
|
|
||||||
authors = get_authors_from_query(q)
|
authors = get_authors_from_query(q)
|
||||||
|
|
|
@ -163,6 +163,7 @@ async def create_reaction(_, info, reaction):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
shout = session.query(Shout).where(Shout.id == reaction["shout"]).one()
|
shout = session.query(Shout).where(Shout.id == reaction["shout"]).one()
|
||||||
author = session.query(Author).where(Author.user == user_id).first()
|
author = session.query(Author).where(Author.user == user_id).first()
|
||||||
|
if shout and author:
|
||||||
reaction["created_by"] = author.id
|
reaction["created_by"] = author.id
|
||||||
if reaction["kind"] in [ReactionKind.DISLIKE.name, ReactionKind.LIKE.name]:
|
if reaction["kind"] in [ReactionKind.DISLIKE.name, ReactionKind.LIKE.name]:
|
||||||
existing_reaction = (
|
existing_reaction = (
|
||||||
|
|
|
@ -210,7 +210,7 @@ input TopicInput {
|
||||||
input ReactionInput {
|
input ReactionInput {
|
||||||
kind: ReactionKind!
|
kind: ReactionKind!
|
||||||
shout: Int!
|
shout: Int!
|
||||||
range: String
|
quote: String
|
||||||
body: String
|
body: String
|
||||||
reply_to: Int
|
reply_to: Int
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user