feat: adds report for blocks today

This commit is contained in:
Iain Learmonth 2023-10-23 17:33:17 +01:00
parent d84d74ae0f
commit 64c6414fb8
3 changed files with 50 additions and 1 deletions

21
app/portal/report.py Normal file
View file

@ -0,0 +1,21 @@
from flask import Blueprint, render_template
from flask.typing import ResponseReturnValue
from sqlalchemy import func, and_
from app.extensions import db
from app.models.mirrors import Proxy, Origin
report = Blueprint("report", __name__)
@report.route("/blocks", methods=['GET'])
def report_blocks() -> ResponseReturnValue:
blocked_today = db.session.query(
Origin.domain_name,
Origin.description,
Proxy.added,
Proxy.deprecated,
Proxy.deprecation_reason
).join(Origin, Origin.id == Proxy.origin_id
).filter(and_(Proxy.deprecated > func.current_date(), Proxy.deprecation_reason.like('block_%'))).all()
return render_template("report_blocks.html.j2", blocked_today=blocked_today)