diff options
| author | user <user@node5.net> | 2024-03-23 22:24:06 +0100 |
|---|---|---|
| committer | user <user@node5.net> | 2024-03-23 22:24:06 +0100 |
| commit | b70a9b7ed2f5ebea9d35d9bdf4a666b8cfdce29b (patch) | |
| tree | 3d20ef20b2835e004489b01f853c861350a2b14a /src/db_handler.py | |
| parent | e06d7f926833d6fba19e57cb2211696e0bdbc6ad (diff) | |
chart stacked grouped by ip address
Diffstat (limited to 'src/db_handler.py')
| -rw-r--r-- | src/db_handler.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/db_handler.py b/src/db_handler.py index d607aee..033b11a 100644 --- a/src/db_handler.py +++ b/src/db_handler.py @@ -56,7 +56,23 @@ LIMIT 1; return password -def get_histogram() -> str: +def get_histogram_detailed() -> str: + with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn: + with conn.cursor() as cur: + cur.execute(""" +SELECT count(la.id) as total_count, date_trunc('hour', la.timestamp) as date, cn.ip +FROM login_attempt la +JOIN connection cn on cn.id = la.connection +GROUP BY date_trunc('hour', la.timestamp), cn.ip +ORDER BY date_trunc('hour', la.timestamp) DESC +LIMIT 48; +; + """) + histogram = cur.fetchall() + return histogram + + +def get_histogram_simple() -> str: with psycopg.connect(**db_con_params, row_factory=psycopg.rows.dict_row) as conn: with conn.cursor() as cur: cur.execute(""" |
