From ba1ae288c1ab1948a87c90f77ec21828577effb9 Mon Sep 17 00:00:00 2001 From: abinnz Date: Sat, 24 Oct 2020 12:30:51 +0800 Subject: [PATCH 1/4] fix: sync keep error --- scripts/keep_sync.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/keep_sync.py b/scripts/keep_sync.py index 127b370ad06..f35e6a72838 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 @@ -171,7 +171,7 @@ def parse_points_to_gpx(run_points_data, start_time): { "latitude": point["latitude"], "longitude": point["longitude"], - "elevation": point["verticalAccuracy"], + "elevation": point["verticalAccuracy"] if "verticalAccuracy" in point.keys() else None, "time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000), } ) From 2cbd3202cb50c57e6920053f73c633a6cb2f2678 Mon Sep 17 00:00:00 2001 From: abinnz Date: Sat, 24 Oct 2020 12:32:02 +0800 Subject: [PATCH 2/4] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) 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 From 6369d52fc1a6df266443254c53bb8cdbde77943a Mon Sep 17 00:00:00 2001 From: abinnz Date: Sat, 24 Oct 2020 14:40:41 +0800 Subject: [PATCH 3/4] fix: invalid location_country --- src/utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/utils.js b/src/utils/utils.js index 16165451701..6a550140484 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -34,7 +34,7 @@ const scrollToMap = () => { const locationForRun = (run) => { const location = run.location_country; let [city, province, country] = ['', '', '']; - if (location) { + if (location && location != "None") { // Only for Chinese now const cityMatch = location.match(/[\u4e00-\u9fa5]*市/); const provinceMatch = location.match(/[\u4e00-\u9fa5]*省/); From 47e9e1065e74da234008d4046a5b874243554ce5 Mon Sep 17 00:00:00 2001 From: abinnz Date: Sat, 24 Oct 2020 21:45:27 +0800 Subject: [PATCH 4/4] fix: sync keep error --- scripts/keep_sync.py | 16 ++++++++-------- src/utils/utils.js | 7 +++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/keep_sync.py b/scripts/keep_sync.py index f35e6a72838..8534844c1dd 100644 --- a/scripts/keep_sync.py +++ b/scripts/keep_sync.py @@ -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"] if "verticalAccuracy" in point.keys() else None, - "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 6a550140484..4d8d455bd54 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -34,7 +34,7 @@ const scrollToMap = () => { const locationForRun = (run) => { const location = run.location_country; let [city, province, country] = ['', '', '']; - if (location && location != "None") { + if (location) { // Only for Chinese now const cityMatch = location.match(/[\u4e00-\u9fa5]*市/); const provinceMatch = location.match(/[\u4e00-\u9fa5]*省/); @@ -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; }