From b18e42a10befbdedca7303b7629ecccc4377644b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 20 Jun 2023 07:27:48 +0200 Subject: [PATCH] Continued: - avoided local variables --- api.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/api.py b/api.py index 16db02b..87f7145 100644 --- a/api.py +++ b/api.py @@ -271,22 +271,16 @@ def rss(request: Request, domain: str = None): fba.cursor.execute("SELECT blocker, blocked, block_level, reason, first_seen, last_seen FROM blocks ORDER BY first_seen DESC LIMIT ?", [config.get("rss_limit")]) result = fba.cursor.fetchall() - blocklist = [] - for blocker, blocked, block_level, reason, first_seen, last_seen in result: - first_seen = utils.format_datetime(datetime.fromtimestamp(first_seen)) - if reason is None or reason == "": - reason = "No reason provided." - else: - reason = "Provided reason: '" + reason + "'" + for row in result: blocklist.append({ - "blocker" : blocker, - "blocked" : blocked, - "block_level": block_level, - "reason" : reason, - "first_seen" : first_seen, - "last_seen" : last_seen, + "blocker" : row[0], + "blocked" : row[1], + "block_level": row[2], + "reason" : "Provided reason: '" + row[3] + "'" if row[3] is not None and row[3] != "" else "No reason provided.", + "first_seen" : utils.format_datetime(datetime.fromtimestamp(row[4])), + "last_seen" : utils.format_datetime(datetime.fromtimestamp(row[5])), }) return templates.TemplateResponse("rss.xml", { -- 2.39.5