Snapshot. Get closer to new stations table.

This commit is contained in:
W1CDN 2023-06-24 21:30:05 -05:00
parent 1362558deb
commit 8972c8d447
3 changed files with 12 additions and 3 deletions

View File

@ -76,7 +76,7 @@ def unique_stations(conn):
:return: :return:
""" """
cur = conn.cursor() 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() rows = cur.fetchall()
return rows return rows

View File

@ -82,6 +82,8 @@ def main():
conn = get_db_connection() conn = get_db_connection()
for frame in ki.read(min_frames=1): for frame in ki.read(min_frames=1):
a = aprslib.parse(str(frame)) 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_call'] = config['Settings']['station_call']
a['station_lat'] = config['Settings']['station_lat'] a['station_lat'] = config['Settings']['station_lat']
a['station_lon'] = config['Settings']['station_lon'] a['station_lon'] = config['Settings']['station_lon']
@ -94,6 +96,9 @@ def main():
sql = f"INSERT INTO frames ({attrib_names}) VALUES ({attrib_values})" sql = f"INSERT INTO frames ({attrib_names}) VALUES ({attrib_values})"
# Insert data # Insert data
conn.execute(sql, list(a.values())) conn.execute(sql, list(a.values()))
# TODO update stations table here
conn.commit() conn.commit()
# TODO remove packets that are older ('created') than a limit set in config.ini # TODO remove packets that are older ('created') than a limit set in config.ini

View File

@ -39,11 +39,15 @@ Coming soon, see <a href="https://amiok.net/gitea/W1CDN/aprs_tool/issues/16">htt
<table> <table>
<tr> <tr>
<th> raw </th> <th> from </th>
<th> last heard (utc) </th>
<th> count </th>
</tr> </tr>
{% for i in stations %} {% for i in stations %}
<tr> <tr>
<td> {{ i['raw'] }} </td> <td> <a href="https://digi.w1cdn.net/aprs_api/packets?from={{ i['from'] }}">{{ i['from'] }}</a> </td>
<td> {{ i['created'] }} </td>
<td> {{ i['COUNT(id)']}} </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>