mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
display posts in DB on /bot/accounts
This commit is contained in:
parent
fc45f4c4c0
commit
c38f01b07a
3 changed files with 10 additions and 2 deletions
|
@ -100,3 +100,5 @@ accounts = cursor.fetchall()
|
|||
cursor.close()
|
||||
with Pool(8) as p:
|
||||
p.map(scrape_posts, accounts)
|
||||
|
||||
#TODO: other cron tasks should be done here, like updating profile pictures
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<div class="panel-text">
|
||||
{% set handle_list = user['fedi_id'].split('@') %}
|
||||
<div class="panel-name">@{{ handle_list[1] }}<span class="subtle tiny">@{{ handle_list[2] }}</span></div>
|
||||
<div class="panel-status">{{ "Active" if user['enabled'] else "Inactive" }}</div>
|
||||
<div class="panel-status">{{ "Active" if user['enabled'] else "Inactive" }}, {{ post_count[user['fedi_id']] }} posts in database</div>
|
||||
</div>
|
||||
<div class="panel-actions">
|
||||
<a class="button btn-secondary" href="/bot/accounts/toggle/{{ user['fedi_id'] }}" title="Turn on/off"><i class="fas fa-power-off"></i></a><a class="button btn-dangerous" href="/bot/accounts/delete/{{ user['fedi_id'] }}" title="Delete"><i class="fas fa-trash"></i></a>
|
||||
|
|
8
webui.py
8
webui.py
|
@ -128,6 +128,7 @@ def bot_accounts(id):
|
|||
c.execute("SELECT COUNT(*) FROM `bot_learned_accounts` WHERE `bot_id` = %s", (id,))
|
||||
user_count = c.fetchone()[0]
|
||||
users = {}
|
||||
post_count = {}
|
||||
|
||||
if user_count > 0:
|
||||
dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
|
||||
|
@ -135,9 +136,14 @@ def bot_accounts(id):
|
|||
users = dc.fetchall()
|
||||
dc.close()
|
||||
|
||||
post_count = {}
|
||||
for user in users:
|
||||
c.execute("SELECT COUNT(*) FROM `posts` WHERE `fedi_id` = %s", (user['fedi_id'],))
|
||||
post_count[user['fedi_id']] = c.fetchone()[0]
|
||||
|
||||
c.close()
|
||||
|
||||
return render_template("bot_accounts.html", users = users)
|
||||
return render_template("bot_accounts.html", users = users, post_count = post_count)
|
||||
|
||||
@app.route("/bot/accounts/add", methods = ['GET', 'POST'])
|
||||
def bot_accounts_add():
|
||||
|
|
Loading…
Reference in a new issue