Skip to content

Commit

Permalink
Merge pull request #20 from abinnz/master
Browse files Browse the repository at this point in the history
修复同步keep数据出现的错误
  • Loading branch information
yihong0618 authored Oct 24, 2020
2 parents 8f72090 + 900a44e commit f6c5058
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ db.csv
danpalmer.sql

.mypy_cache

.vscode
18 changes: 9 additions & 9 deletions scripts/keep_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

1 comment on commit f6c5058

@vercel
Copy link

@vercel vercel bot commented on f6c5058 Oct 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.