diff --git a/.gitignore b/.gitignore index 7d84299efe9..d88b2d317c8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ db.csv danpalmer.sql .mypy_cache + +.vscode \ No newline at end of file diff --git a/scripts/keep_sync.py b/scripts/keep_sync.py index 127b370ad06..8534844c1dd 100644 --- a/scripts/keep_sync.py +++ b/scripts/keep_sync.py @@ -86,7 +86,7 @@ def parse_raw_data_to_nametuple(run_data, old_gpx_ids, with_download_gpx=False): keep_id = run_data["id"].split("_")[1] start_time = run_data["startTime"] - if run_data.get("vendor").get("genre", "") == "KeepApp": + if run_data.get("vendor").get("genre", "") == "KeepApp" and run_data.get("rawDataURL") != '': raw_data_url = run_data.get("rawDataURL") r = requests.get(raw_data_url) # string strart with `H4sIAAAAAAAA` --> decode and unzip @@ -167,14 +167,14 @@ def parse_points_to_gpx(run_points_data, start_time): # future to support heart rate points_dict_list = [] for point in run_points_data: - points_dict_list.append( - { - "latitude": point["latitude"], - "longitude": point["longitude"], - "elevation": point["verticalAccuracy"], - "time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000), - } - ) + points_dict = { + "latitude": point["latitude"], + "longitude": point["longitude"], + "time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000), + } + if "verticalAccuracy" in point: + points_dict["elevation"] = point["verticalAccuracy"] + points_dict_list.append(points_dict) gpx = gpxpy.gpx.GPX() gpx.nsmap["gpxtpx"] = "http://www.garmin.com/xmlschemas/TrackPointExtension/v1" gpx_track = gpxpy.gpx.GPXTrack() diff --git a/src/utils/utils.js b/src/utils/utils.js index 16165451701..4d8d455bd54 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -46,7 +46,10 @@ const locationForRun = (run) => { } const l = location.split(','); // or to handle keep location format - const countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/) || l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/); + let countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/); + if (!countryMatch && l.length >= 3) { + countryMatch = l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/); + } if (countryMatch) { [country] = countryMatch; }