This commit is contained in:
Aevann1 2022-01-29 05:19:47 +02:00
parent 9a7cdc4d25
commit 927a03b961
3 changed files with 14 additions and 4 deletions

View file

@ -548,6 +548,16 @@ class User(Base):
posts = g.db.query(Subscription.submission_id).filter_by(user_id=self.id).all()
return [x[0] for x in posts]
@property
@lazy
def saved_count(self):
return g.db.query(SaveRelationship.submission_id).filter(SaveRelationship.user_id == self.id).count()
@property
@lazy
def saved_comment_count(self):
return g.db.query(SaveRelationship.comment_id).filter(SaveRelationship.user_id == self.id).count()
@lazy
def saved_idlist(self, page=1):

View file

@ -609,10 +609,10 @@
</li>
{% if u.id == v.id %}
<li class="nav-item">
<a class="nav-link {% if 'saved' in request.path %}active{% endif %}" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/posts">Saved Posts</a>
<a class="nav-link {% if 'saved' in request.path %}active{% endif %}" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/posts">Saved Posts <span class="count">({{u.saved_count}})</span></a>
</li>
<li class="nav-item">
<a class="nav-link" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/comments">Saved Comments</a>
<a class="nav-link" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/comments">Saved Comments <span class="count">({{u.saved_comment_count}})</span></a>
</li>
{% endif %}
</ul>

View file

@ -14,10 +14,10 @@
</li>
{% if u.id == v.id %}
<li class="nav-item">
<a class="nav-link" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/posts">Saved Posts</a>
<a class="nav-link" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/posts">Saved Posts <span class="count">({{u.saved_count}})</span></a>
</li>
<li class="nav-item">
<a class="nav-link {% if 'saved' in request.path %}active{% endif %}" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/comments">Saved Comments</a>
<a class="nav-link {% if 'saved' in request.path %}active{% endif %}" style="font-size: .9rem !important; padding: .75rem .4rem !important;" href="/@{{u.username}}/saved/comments">Saved Comments <span class="count">({{u.saved_comment_count}})</span></a>
</li>
{% endif %}
</ul>