Modify SQL query to use 'bips' table instead of bans for the count

Use bips as it has the list of all persisted banned IPs. This should fix the incorrect count of banned IPs in the dashboard

Signed-off-by: Calvin Hobbes <5r91nrqo@duck.com>
This commit is contained in:
Calvin Hobbes 2025-11-11 15:44:06 +00:00 committed by GitHub
parent 84be9eafa4
commit dfe71e3917
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,12 +9,12 @@ def _get_f2b_data(db_path):
con = sqlite3.connect(db_path)
cur = con.cursor()
results = cur.execute("""
SELECT jails.name,
COUNT(bans.ip) AS bans,
(SELECT DISTINCT bans.ip from bans where jails.name = bans.jail ORDER BY timeofban DESC) as last_ban,
(SELECT DISTINCT bans.data from bans where jails.name = bans.jail ORDER BY timeofban DESC) as data
FROM jails
LEFT JOIN bans ON jails.name=bans.jail
SELECT jails.name,
COUNT(bips.ip) AS bans,
(SELECT DISTINCT bips.ip from bips where jails.name = bips.jail ORDER BY timeofban DESC) as last_ban,
(SELECT DISTINCT bips.data from bips where jails.name = bips.jail ORDER BY timeofban DESC) as data
FROM jails
LEFT JOIN bips ON jails.name=bips.jail
GROUP BY jails.name
""").fetchall()
con.close()