diff options
| author | user <user@node5.net> | 2024-03-23 18:52:37 +0100 |
|---|---|---|
| committer | user <user@node5.net> | 2024-03-23 18:52:37 +0100 |
| commit | e06d7f926833d6fba19e57cb2211696e0bdbc6ad (patch) | |
| tree | a3a79b5ec8d0ee254950b53cb9f894e946c7bea9 /src/db_handler.py | |
| parent | f379b1c78cc224581fac16541e5bc3b6ccbc5dd1 (diff) | |
add login attempts chart
Diffstat (limited to 'src/db_handler.py')
| -rw-r--r-- | src/db_handler.py | 15 |
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 |
