enable comma seperated searches

This commit is contained in:
xss 2022-11-04 21:24:52 +11:00
parent 6cc3804bb2
commit a8ad0bffd0
3 changed files with 10 additions and 10 deletions

View File

@ -122,7 +122,7 @@ def get_telem(event, context):
lt = requested_time + timedelta(0, 1)
gte = requested_time - timedelta(0, duration)
path = f"ham-telm-{lt.year:2}-{lt.month:02},telm-{gte.year:2}-{gte.month:02}/_search"
path = f"ham-telm-{lt.year:2}-{lt.month:02},ham-telm-{gte.year:2}-{gte.month:02}/_search"
payload = {
"timeout": "30s",
"size": 0,
@ -209,13 +209,12 @@ def get_telem(event, context):
}
if "queryStringParameters" in event:
if "payload_callsign" in event["queryStringParameters"]:
payload["query"]["bool"]["filter"].append(
{
"match_phrase": {
"payload_callsign": str(event["queryStringParameters"]["payload_callsign"])
payloads = str(event["queryStringParameters"]["payload_callsign"]).split(",")
payload["query"]["bool"]["must"] = {
"bool": {
"should": [ {"match_phrase": {"payload_callsign": x}} for x in payloads ]
}
}
)
results = es.request(json.dumps(payload), path, "POST")
output = {
sonde["key"]: {

View File

@ -3,12 +3,13 @@ import base64
import zlib
response = get_telem_full(
response = get_telem(
{
"pathParameters": {
"payload_callsign" : "HORUSBINARY"
},
"queryStringParameters":{
"payload_callsign" : "NOB14,VE6AGD-11",
"last": "10800",
"datetime": "2022-06-26T08:30:00.000001Z",
"format": "kml"

View File

@ -26,5 +26,5 @@ def handler(event, context):
return redirect("https://cloudwatch.amazonaws.com/dashboard.html?dashboard=SondeHub&context=eyJSIjoidXMtZWFzdC0xIiwiRCI6ImN3LWRiLTE0Mzg0MTk0MTc3MyIsIlUiOiJ1cy1lYXN0LTFfZ2NlT3hwUnp0IiwiQyI6IjNuOWV0Y2ZxZm9zdm11aTc0NTYwMWFzajVzIiwiSSI6InVzLWVhc3QtMTo0ODI5YmQ4MC0yZmYzLTQ0MDktYjI1ZS0yOTE4MTM5YTgwM2MiLCJNIjoiUHVibGljIn0%3D")
if uri != '/':
uri = re.sub(r"^\/","", uri)
return redirect('https://amateur.sondehub.org/?sondehub=1#!f=' + sonde + '&mz=9&qm=All&q=' + sonde)
return redirect('https://amateur.sondehub.org/?sondehub=1#!f=' + uri + '&mz=9&qm=All&q=' + uri)
return request