adding users back in with better query

This commit is contained in:
Alan Roberts 2024-09-05 13:24:30 -04:00
parent 2249140bf3
commit 6e3de6e9e2
2 changed files with 4 additions and 2 deletions

View file

@ -93,8 +93,8 @@ class Instance(db.Model):
def known_communities_count(self): def known_communities_count(self):
return db.session.execute(text(f'SELECT count(*) FROM community WHERE instance_id = {self.id}')).all()[0].count return db.session.execute(text(f'SELECT count(*) FROM community WHERE instance_id = {self.id}')).all()[0].count
# def known_users_count(self): def known_users_count(self):
# return db.session.execute(text(f'SELECT count(DISTINCT instance_id) as count FROM USER')).all()[0].count return db.session.execute(text(f'SELECT count(*) FROM "user" WHERE instance_id = {self.id}')).all()[0].count
def __repr__(self): def __repr__(self):
return '<Instance {}>'.format(self.domain) return '<Instance {}>'.format(self.domain)

View file

@ -23,6 +23,7 @@
<th>Software</th> <th>Software</th>
<th>Version</th> <th>Version</th>
<th title="{{ _('Known Communities') }}">Communities</td> <th title="{{ _('Known Communities') }}">Communities</td>
<th title="{{ _('Known Users') }}">Users</td>
<th>Posts</th> <th>Posts</th>
<th>Post Replies</th> <th>Post Replies</th>
<th>Vote Weight</th> <th>Vote Weight</th>
@ -37,6 +38,7 @@
<td>{{ instance.software }}</td> <td>{{ instance.software }}</td>
<td>{{ instance.version if instance.version }}</td> <td>{{ instance.version if instance.version }}</td>
<td>{{ instance.known_communities_count() }}</td> <td>{{ instance.known_communities_count() }}</td>
<td>{{ instance.known_users_count() }}</td>
<td>{{ instance.post_count() }}</td> <td>{{ instance.post_count() }}</td>
<td>{{ instance.post_replies_count() }}</td> <td>{{ instance.post_replies_count() }}</td>
<td>{{ instance.vote_weight }}</td> <td>{{ instance.vote_weight }}</td>