add user count badge

This commit is contained in:
codl 2017-09-06 16:19:13 +02:00
parent 8297a88c51
commit 2190d5dd86
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 13 additions and 1 deletions

View File

@ -5,7 +5,8 @@ import lib.twitter
import lib.mastodon
from lib.auth import require_auth, require_auth_api, csrf,\
set_session_cookie, get_viewer_session, get_viewer
from model import Session, TwitterArchive, MastodonApp, MastodonInstance
from model import Session, TwitterArchive, MastodonApp, MastodonInstance,\
Account
from app import app, db, sentry, limiter
import tasks
from zipfile import BadZipFile
@ -351,3 +352,14 @@ def delete_reason():
get_viewer().reason = None
db.session.commit()
return jsonify(status='success')
@app.route('/api/badge/users')
def users_badge():
count = (
Account.query.filter(Account.policy_enabled)
.filter(~Account.dormant)
.count()
)
return redirect(
"https://img.shields.io/badge/active%20users-{}-blue.svg"
.format(count))