From 8972c8d4477828dc85a9aa32c450ebcc7583d2ee Mon Sep 17 00:00:00 2001 From: W1CDN Date: Sat, 24 Jun 2023 21:30:05 -0500 Subject: [PATCH] Snapshot. Get closer to new `stations` table. --- api_app.py | 2 +- tcp_kiss_send_recv.py | 5 +++++ templates/index.html | 8 ++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api_app.py b/api_app.py index 4840fca..bf55831 100644 --- a/api_app.py +++ b/api_app.py @@ -76,7 +76,7 @@ def unique_stations(conn): :return: """ cur = conn.cursor() - cur.execute('SELECT *, MAX(id) FROM frames GROUP BY "from" ORDER BY MAX(id) DESC') + cur.execute('SELECT *, MAX(id), COUNT(id) FROM frames GROUP BY "from" ORDER BY MAX(id) DESC') rows = cur.fetchall() return rows diff --git a/tcp_kiss_send_recv.py b/tcp_kiss_send_recv.py index 4e6fe5a..c168b8f 100644 --- a/tcp_kiss_send_recv.py +++ b/tcp_kiss_send_recv.py @@ -82,6 +82,8 @@ def main(): conn = get_db_connection() for frame in ki.read(min_frames=1): a = aprslib.parse(str(frame)) + # Add information about *this* station - might be useful for + # combining data across stations in the future. a['station_call'] = config['Settings']['station_call'] a['station_lat'] = config['Settings']['station_lat'] a['station_lon'] = config['Settings']['station_lon'] @@ -94,6 +96,9 @@ def main(): sql = f"INSERT INTO frames ({attrib_names}) VALUES ({attrib_values})" # Insert data conn.execute(sql, list(a.values())) + + # TODO update stations table here + conn.commit() # TODO remove packets that are older ('created') than a limit set in config.ini diff --git a/templates/index.html b/templates/index.html index 5678d2e..22bf7eb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -39,11 +39,15 @@ Coming soon, see htt - + + + {% for i in stations %} - + + + {% endfor %}
raw from last heard (utc) count
{{ i['raw'] }} {{ i['from'] }} {{ i['created'] }} {{ i['COUNT(id)']}}