You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
suchwow/suchwow/routes/leaderboard.py

31 lines
899 B

from datetime import datetime, timedelta
from os import path
from flask import render_template, Blueprint, request, session, flash
from flask import send_from_directory, redirect, url_for, current_app
from werkzeug.utils import secure_filename
from suchwow import wownero
from suchwow.models import Post
from suchwow.utils.helpers import rw_cache, get_top_posters, get_top_posts
bp = Blueprint("leaderboard", "leaderboard")
@bp.route("/leaderboards/top_posters")
def top_posters():
top_posters = get_top_posters()
return render_template("leaderboard.html", posters=top_posters)
@bp.route("/leaderboards/top_posts")
def top_posts():
days = request.args.get('days', 1)
try:
days = int(days)
except:
days = 1
if days not in [1, 3, 7, 30]:
days = 7
posts = get_top_posts(days)
return render_template("post/top.html", posts=posts, days=days)