summaryrefslogtreecommitdiff
path: root/src/db_handler.py
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-03-23 18:52:37 +0100
committeruser <user@node5.net>2024-03-23 18:52:37 +0100
commite06d7f926833d6fba19e57cb2211696e0bdbc6ad (patch)
treea3a79b5ec8d0ee254950b53cb9f894e946c7bea9 /src/db_handler.py
parentf379b1c78cc224581fac16541e5bc3b6ccbc5dd1 (diff)
add login attempts chart
Diffstat (limited to 'src/db_handler.py')
-rw-r--r--src/db_handler.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/db_handler.py b/src/db_handler.py
index 7766da1..d607aee 100644
--- a/src/db_handler.py
+++ b/src/db_handler.py
@@ -54,3 +54,18 @@ LIMIT 1;
password = cur.fetchone()['password']
return password
+
+
+def get_histogram() -> str:
+ with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn:
+ with conn.cursor() as cur:
+ cur.execute("""
+SELECT count(id) as total_count, date_trunc('hour', timestamp) as date
+FROM login_attempt
+GROUP BY date_trunc('hour', timestamp)
+ORDER BY date_trunc('hour', timestamp)
+LIMIT 48
+;
+ """)
+ histogram = cur.fetchall()
+ return histogram