update swagger for recover stats, fix station parsing errors

This commit is contained in:
Michaela Wheeler 2021-12-20 13:16:07 +11:00
parent 6522af876c
commit f97ed9ee56
2 changed files with 64 additions and 15 deletions

View File

@ -51,7 +51,10 @@ def lambda_handler(event, context):
).total_seconds() ).total_seconds()
except: except:
pass pass
payload = json.loads(event["body"]) try:
payload = json.loads(event["body"])
except:
return {"statusCode": 400, "body": "JSON decode issue"}
print(payload) print(payload)
if "user-agent" in event["headers"]: if "user-agent" in event["headers"]:
event["time_server"] = datetime.datetime.now().isoformat() event["time_server"] = datetime.datetime.now().isoformat()
@ -63,7 +66,7 @@ def lambda_handler(event, context):
# clean up None reports # clean up None reports
if "uploader_position" in payload and None in payload["uploader_position"]: if "uploader_position" in payload and None == payload["uploader_position"]:
payload.pop("uploader_position", None) payload.pop("uploader_position", None)
if "uploader_position" in payload: if "uploader_position" in payload:
@ -137,19 +140,7 @@ if __name__ == "__main__":
"timeEpoch": 1612051825409, "timeEpoch": 1612051825409,
}, },
"body": """ "body": """
{ {"software_name": "radiosonde_auto_rx", "software_version": "1.5.8-beta2", "uploader_callsign": "LZ3DJ-18", "uploader_position": null, "uploader_antenna": "Dipole", "uploader_contact_email": "none@none.com", "mobile": false}
"software_name": "radiosonde_auto_rx",
"software_version": "1.5.5",
"uploader_callsign": "mwheeler",
"uploader_position": [
-37.8136,
144.9631,
90
],
"uploader_antenna": "mwheeler",
"uploader_contact_email": "none@none.com",
"mobile": false
}
""", """,
"isBase64Encoded": False, "isBase64Encoded": False,
} }

View File

@ -279,6 +279,40 @@ paths:
description: Returns a list of recovery objects description: Returns a list of recovery objects
schema: schema:
$ref: "#/definitions/recovery_results_format" $ref: "#/definitions/recovery_results_format"
/recovered/stats:
get:
summary: Request Recovery Stats
description: >
Use this to get the recovery stats
produces:
- "application/json"
parameters:
- in: query
name: lat
type: number
description: "Latitude - if specified, lon and distance are required. Eg: -34.9285"
- in: query
name: lon
description: "Longitude - if specified, lat and distance are required Eg: 138.6007"
type: number
- in: query
name: distance
description: "Distance in meters - if specified, lat and lon are required"
type: number
- in: query
name: duration
description: "How far back to search in seconds. Defaults to foreverl"
type: number
- in: query
name: datetime
description: "End time to query as an ISO-8601 time string. Defaults to now. Example: `2021-02-02T11:27:38.634Z`"
type: string
format: date-time
responses:
200:
description: Returns a list of recovery objects
schema:
$ref: "#/definitions/recovery_stats"
/sites: /sites:
get: get:
description: Radiosonde launch sites description: Radiosonde launch sites
@ -423,6 +457,30 @@ definitions:
description: description:
description: Description of the recovery effort description: Description of the recovery effort
type: string type: string
recovery_stats:
type: object
required:
- total
- recovered
- failed
- chaser_count
- top_chasers
properties:
total:
type: number
description: Total number of serial numbers that have had at least one attempt
recovered:
description: Total number of serial numbers that have been recovered
type: number
failed:
description: Total number of serial numbers that have a failed recovered attempt
type: number
chaser_count:
description: Total number of unique recovery names
type: number
top_chasers:
description: "chaser name : number of attempted recoveries"
type: object
sonde_query_results_format: sonde_query_results_format:
type: object type: object
properties: properties: