commit
92e5af3184
|
@ -180,6 +180,7 @@ async def migrate(entry, storage):
|
||||||
def migrate_2stage(old_comment, idmap):
|
def migrate_2stage(old_comment, idmap):
|
||||||
if old_comment.get('body'):
|
if old_comment.get('body'):
|
||||||
new_id = idmap.get(old_comment.get('oid'))
|
new_id = idmap.get(old_comment.get('oid'))
|
||||||
|
new_id = idmap.get(old_comment.get('_id'))
|
||||||
if new_id:
|
if new_id:
|
||||||
new_replyto_id = None
|
new_replyto_id = None
|
||||||
old_replyto_id = old_comment.get("replyTo")
|
old_replyto_id = old_comment.get("replyTo")
|
||||||
|
|
|
@ -225,32 +225,32 @@ async def load_reactions_by(_, _info, by, limit=50, offset=0):
|
||||||
:return: Reaction[]
|
:return: Reaction[]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CreatedByUser = aliased(User)
|
|
||||||
ReactedShout = aliased(Shout)
|
|
||||||
q = select(
|
q = select(
|
||||||
Reaction, CreatedByUser, ReactedShout
|
Reaction, User, Shout
|
||||||
).join(
|
).join(
|
||||||
CreatedByUser, Reaction.createdBy == CreatedByUser.id
|
User, Reaction.createdBy == User.id
|
||||||
).join(
|
).join(
|
||||||
ReactedShout, Reaction.shout == ReactedShout.id
|
Shout, Reaction.shout == Shout.id
|
||||||
)
|
)
|
||||||
|
|
||||||
if by.get("shout"):
|
if by.get("shout"):
|
||||||
aliased_shout = aliased(Shout)
|
q = q.filter(Shout.slug == by["shout"])
|
||||||
q = q.join(aliased_shout).filter(aliased_shout.slug == by["shout"])
|
|
||||||
elif by.get("shouts"):
|
elif by.get("shouts"):
|
||||||
aliased_shout = aliased(Shout)
|
q = q.filter(Shout.shout.in_(by["shouts"]))
|
||||||
q = q.join(aliased_shout).filter(aliased_shout.shout.in_(by["shouts"]))
|
|
||||||
if by.get("createdBy"):
|
if by.get("createdBy"):
|
||||||
aliased_user = aliased(User)
|
q = q.filter(User.slug == by.get("createdBy"))
|
||||||
q = q.join(aliased_user).filter(aliased_user.slug == by.get("createdBy"))
|
|
||||||
if by.get("topic"):
|
if by.get("topic"):
|
||||||
# TODO: check
|
# TODO: check
|
||||||
q = q.filter(Shout.topics.contains(by["topic"]))
|
q = q.filter(Shout.topics.contains(by["topic"]))
|
||||||
|
|
||||||
if by.get("comment"):
|
if by.get("comment"):
|
||||||
q = q.filter(func.length(Reaction.body) > 0)
|
q = q.filter(func.length(Reaction.body) > 0)
|
||||||
|
|
||||||
if len(by.get('search', '')) > 2:
|
if len(by.get('search', '')) > 2:
|
||||||
q = q.filter(Reaction.body.ilike(f'%{by["body"]}%'))
|
q = q.filter(Reaction.body.ilike(f'%{by["body"]}%'))
|
||||||
|
|
||||||
if by.get("days"):
|
if by.get("days"):
|
||||||
after = datetime.now(tz=timezone.utc) - timedelta(days=int(by["days"]) or 30)
|
after = datetime.now(tz=timezone.utc) - timedelta(days=int(by["days"]) or 30)
|
||||||
q = q.filter(Reaction.createdAt > after)
|
q = q.filter(Reaction.createdAt > after)
|
||||||
|
@ -259,7 +259,7 @@ async def load_reactions_by(_, _info, by, limit=50, offset=0):
|
||||||
order_field = by.get("sort", "").replace('-', '') or Reaction.createdAt
|
order_field = by.get("sort", "").replace('-', '') or Reaction.createdAt
|
||||||
|
|
||||||
q = q.group_by(
|
q = q.group_by(
|
||||||
Reaction.id, CreatedByUser.id, ReactedShout.id
|
Reaction.id, User.id, Shout.id
|
||||||
).order_by(
|
).order_by(
|
||||||
order_way(order_field)
|
order_way(order_field)
|
||||||
)
|
)
|
||||||
|
|
|
@ -50,6 +50,7 @@ type Author {
|
||||||
userpic: String
|
userpic: String
|
||||||
caption: String # only for full shout
|
caption: String # only for full shout
|
||||||
bio: String
|
bio: String
|
||||||
|
about: String
|
||||||
links: [String]
|
links: [String]
|
||||||
stat: AuthorStat
|
stat: AuthorStat
|
||||||
roles: [Role] # in different communities
|
roles: [Role] # in different communities
|
||||||
|
|
Loading…
Reference in New Issue
Block a user