furizon_webint/stats.py

29 lines
1.3 KiB
Python
Raw Normal View History

2023-01-19 16:02:57 +00:00
from sanic.response import html
from sanic import Blueprint
2023-01-19 16:02:57 +00:00
from ext import *
bp = Blueprint("stats", url_prefix="/manage")
2024-01-04 11:14:43 +00:00
@bp.route("/sponsorcount")
async def sponsor_count(request, order: Order):
await request.app.ctx.om.updateCache()
orders = {key:value for key,value in sorted(request.app.ctx.om.cache.items(), key=lambda x: x[1].ans('fursona_name')) if value.status not in ['c', 'e']}
2024-01-04 11:14:43 +00:00
tpl = request.app.ctx.tpl.get_template('sponsorcount.html')
return html(tpl.render(orders=orders, order=order))
2023-01-19 16:02:57 +00:00
@bp.route("/nosecount")
async def nose_count(request, order: Order):
2023-12-30 10:27:42 +00:00
await request.app.ctx.om.updateCache()
2023-01-19 16:02:57 +00:00
orders = {key:value for key,value in sorted(request.app.ctx.om.cache.items(), key=lambda x: len(x[1].room_members), reverse=True) if value.status not in ['c', 'e']}
tpl = request.app.ctx.tpl.get_template('nosecount.html')
return html(tpl.render(orders=orders, order=order))
2023-12-30 10:27:42 +00:00
@bp.route("/fursuitcount")
async def fursuit_count(request, order: Order):
await request.app.ctx.om.updateCache()
orders = {key:value for key,value in sorted(request.app.ctx.om.cache.items(), key=lambda x: x[1].ans('fursona_name')) if value.status not in ['c', 'e']}
2023-12-30 10:27:42 +00:00
tpl = request.app.ctx.tpl.get_template('fursuitcount.html')
return html(tpl.render(orders=orders, order=order))