Add simple map of stations #57

Merged
W1CDN merged 6 commits from map-1 into main 2024-11-20 10:54:30 -06:00
Showing only changes of commit c8f8f28a4a - Show all commits

View File

@ -85,6 +85,19 @@ def select_frames(conn, n, url_params):
cur.execute(sql)
rows = cur.fetchall()
return rows
def select_stations(conn, n):
"""
Query rows in the stations table
:param conn: the Connection object
:return:
"""
cur = conn.cursor()
sql = 'SELECT * FROM stations ORDER BY last_heard_unix DESC LIMIT {n}'.format(n=n)
print(sql)
cur.execute(sql)
rows = cur.fetchall()
return rows
@api_app.route('/')
def index():
@ -215,7 +228,7 @@ class Stations(Resource):
conn = get_db_connection()
# Limit to number of records requested
data = select_all_stations(conn)
data = select_stations(conn, n = n)
# Sort by created date, descending (https://stackoverflow.com/a/45266808)
#data.sort(key=operator.itemgetter('created'), reverse=True)
return {'data':data}, 200 # return data and 200 OK code