add comment count column to submissions
ALTER TABLE submissions add column comment_count integer default 0; update submissions set comment_count=(select count(id) from comments where parent_submission=submissions.id);
This commit is contained in:
parent
428fee9854
commit
33d58691f9
2 changed files with 7 additions and 5 deletions
|
@ -52,6 +52,7 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
stickied = Column(Boolean, default=False)
|
||||
is_pinned = Column(Boolean, default=False)
|
||||
private = Column(Boolean, default=False)
|
||||
comment_count = Column(Integer, default=0)
|
||||
comments = relationship(
|
||||
"Comment",
|
||||
lazy="joined",
|
||||
|
@ -95,11 +96,6 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing):
|
|||
def __repr__(self):
|
||||
return f"<Submission(id={self.id})>"
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def comment_count(self):
|
||||
return len(self.comments)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def score(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue