Coverage for seedboxsync/front/views/stats.py: 100%
15 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-26 17:46 +0000
1#
2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr>
3#
4# For the full copyright and license information, please view the LICENSE
5# file that was distributed with this source code.
6#
7"""SeedboxSync Flask vierw for stats."""
9from flask import render_template
10from humanize import filesize
11from seedboxsync.core.dao import Download
12from seedboxsync.front.cache import cache
13from seedboxsync.front.utils import init_flash
14from seedboxsync.front.views import bp
17@bp.route("/stats")
18@cache.cached(timeout=300) # pyright: ignore [reportUntypedFunctionDecorator]
19def stats() -> str:
20 """Stats page view."""
21 init_flash()
23 query = Download.select().where(Download.finished != 0)
24 total_files = query.count()
25 total_size = sum([d.seedbox_size for d in query if d.seedbox_size])
27 stats_total = {
28 "files": total_files,
29 "total_size": filesize.naturalsize(total_size, True),
30 }
32 return render_template("stats.html", stats_total=stats_total)