forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-08-07 17:19:53 +02:00
parent c6478a7c52
commit 5686f46a4a
4 changed files with 6 additions and 23 deletions

View File

@ -52,11 +52,6 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing):
post = relationship("Submission")
flags = relationship("CommentFlag", lazy="dynamic")
votes = relationship(
"CommentVote",
lazy="dynamic",
primaryjoin="CommentVote.comment_id==Comment.id")
author = relationship(
"User",
lazy="joined",

View File

@ -55,17 +55,6 @@ class User(Base, Stndrd, Age_times):
newtabexternal = Column(Boolean, default=True)
zzz = Column(Boolean, default=False)
oldreddit = Column(Boolean, default=False)
submissions = relationship(
"Submission",
lazy="dynamic",
primaryjoin="Submission.author_id==User.id",
)
comments = relationship(
"Comment",
lazy="dynamic",
primaryjoin="Comment.author_id==User.id")
votes = relationship("Vote", lazy="dynamic")
commentvotes = relationship("CommentVote", lazy="dynamic")
bio = Column(String, default="")
bio_html = Column(String, default="")
badges = relationship("Badge", lazy="dynamic")
@ -104,11 +93,6 @@ class User(Base, Stndrd, Age_times):
_applications = relationship("OauthApp", lazy="dynamic")
authorizations = relationship("ClientAuth", lazy="dynamic")
saved_posts = relationship(
"SaveRelationship",
lazy="dynamic",
primaryjoin="User.id==SaveRelationship.user_id")
awards = relationship(
"AwardRelationship",
lazy="dynamic",

View File

@ -199,7 +199,7 @@ def get_comment(i, v=None, graceful=False, **kwargs):
return comment
def get_comments(cids, v=None):
def get_comments(cids, v=None, load_parent=False):
if not cids: return []
@ -245,6 +245,10 @@ def get_comments(cids, v=None):
else:
output = g.db.query(Comment).filter(Comment.id.in_(cids)).all()
if load_parent:
parents = [x.parent_comment_id for x in output if x.parent_comment_id]
parents = get_comments(parents, v=v)
return sorted(output, key=lambda x: cids.index(x.id))

View File

@ -34,7 +34,7 @@ def notifications(v):
cids = v.notification_commentlisting(page=page, all_=all_)
next_exists = (len(cids) == 26)
cids = cids[:25]
comments = get_comments(cids, v=v)
comments = get_comments(cids, v=v, load_parent=True)
listing = []
for c in comments: