]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 05:27:48 +0000 (07:27 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 20 Jun 2023 05:27:48 +0000 (07:27 +0200)
- avoided local variables

api.py

diff --git a/api.py b/api.py
index 16db02b1a42e3dfc7e21c03c4955e54718f22f7b..87f7145cfeb7897601a8415d5dffa376f4851217 100644 (file)
--- 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", {