Sort, filter, and limit results at /packets #23
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "sort-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #15, #3.
I wonder if using
aprs_api/packets/<callsign-ssid>
works better on the back end thanaprs_api/packets?from=<callsign-ssid>
.Also, this needs to happen on the query side, so we don't pull all rows and then cut them down every single time:
Should probably run everything through the query anyway.
It might be time to use sqlalchemy or some other way to abstract the database calls. My first pass is pretty ugly.
For example, I should be able to arbitrarily WHERE on any field.
So weird. I uploaded the files to the digi machine and now it shows packets from 2023-04-16.
The packets are still getting into the db, it's the query that is broken. Will have to rethink this when I have a moment.
The query was ordering by row ID by default, I added ORDER BY created DESC.
Now messages don't work (unrelated to recent change):
Missing
msgNo
field.Why does this look like two dicts? Oh, the first part may have gone in fine, and this one is the problem:
{'station_call': 'W1CDN-1', 'station_lat': '47.941500', 'station_lon': '-97.027000'}
Was there an empty/unparsed frame that happened?On live code, moved the rest of the processing inside the try()...else() at
I wonder if the curly braces in the frame are causing problems.
Excited about the latest commit, which allows you to query on any field in the frames table.
I'm not sure if you can do wildcards or not.
I added
LIKE
instead of=
, which will let you do wildcards with%
as in:http://127.0.0.1:5001/packets?created=2023-04%
orhttp://127.0.0.1:5001/packets?from=%UND%
.https://www.sqlitetutorial.net/sqlite-where/
To close #27, is it easier to query on
timestamp
or by the text version ofcreated
?timestamp
actually doesn't seem to make sense. It converts about two days off. Is it what I think it is?Since
created
is stored as text, options arecreated
created
and query string into Unix (maybe withDATETIME
in the db query itself?)What's the use case for this, anyway? I think returning Unix time like https://aprs.fi/page/api and letting the downstream application worry about comparators is fine.
You can also already pull limited time blocks using wildcards on
created
:http://127.0.0.1:5001/packets?created=2023-04%
returns packets in April 2023.In any case, the next thing should be
created_unix
field in db frames tableUgh, because
created
is automatic in the row creation, a direct conversion would mean two more db calls (one to readcreated
, one to write to second column). Probably better to calculatecreated_unix
when writing the row originally.New field
created_unix
works. As a bonus, you can group vaguely by timestamp using a wildcard. For example,http://127.0.0.1:5001/packets?created_unix=1684029%
captures values between 1684029000 and 1684029999 (between Sat May 13 2023 20:50:00 and Sat May 13 2023 21:06:39 GMT-0500).(The same wildcard-tail search will return different results once Unix time gains another order of magnitude, but that's not until 2286.)
A lot of this work can be repurposed for #28, but I'll open a new PR for that.
Letting this branch run on the live system for a bit to see if anything breaks, then will close.