add user count badge
This commit is contained in:
parent
8297a88c51
commit
2190d5dd86
14
routes.py
14
routes.py
|
@ -5,7 +5,8 @@ import lib.twitter
|
||||||
import lib.mastodon
|
import lib.mastodon
|
||||||
from lib.auth import require_auth, require_auth_api, csrf,\
|
from lib.auth import require_auth, require_auth_api, csrf,\
|
||||||
set_session_cookie, get_viewer_session, get_viewer
|
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
|
from app import app, db, sentry, limiter
|
||||||
import tasks
|
import tasks
|
||||||
from zipfile import BadZipFile
|
from zipfile import BadZipFile
|
||||||
|
@ -351,3 +352,14 @@ def delete_reason():
|
||||||
get_viewer().reason = None
|
get_viewer().reason = None
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return jsonify(status='success')
|
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))
|
||||||
|
|
Loading…
Reference in New Issue