mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-03 00:31:25 -08:00
adding comment to explain the sql text call
This commit is contained in:
parent
6e3de6e9e2
commit
6357b2d3d1
1 changed files with 2 additions and 0 deletions
|
@ -84,6 +84,8 @@ class Instance(db.Model):
|
||||||
def votes_are_public(self):
|
def votes_are_public(self):
|
||||||
return self.software.lower() == 'lemmy' or self.software.lower() == 'mbin' or self.software.lower() == 'kbin'
|
return self.software.lower() == 'lemmy' or self.software.lower() == 'mbin' or self.software.lower() == 'kbin'
|
||||||
|
|
||||||
|
# the db execute returns a cursorresult. the all() returns a list with one item in it.
|
||||||
|
# the [0] gets the one sqlalchemy Row object, the Row.count then is the number we show
|
||||||
def post_count(self):
|
def post_count(self):
|
||||||
return db.session.execute(text(f'SELECT count(*) FROM post WHERE instance_id = {self.id}')).all()[0].count
|
return db.session.execute(text(f'SELECT count(*) FROM post WHERE instance_id = {self.id}')).all()[0].count
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue