Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复同步keep数据出现的错误 #20

Merged
merged 4 commits into from
Oct 24, 2020
Merged

Conversation

abinnz
Copy link
Contributor

@abinnz abinnz commented Oct 24, 2020

No description provided.

@vercel
Copy link

vercel bot commented Oct 24, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/yihong0618/running-page/8778lz4dz
✅ Preview: https://running-page-git-master.yihong0618.vercel.app

@@ -34,7 +34,7 @@ const scrollToMap = () => {
const locationForRun = (run) => {
const location = run.location_country;
let [city, province, country] = ['', '', ''];
if (location) {
if (location && location != "None") {
Copy link
Owner

Choose a reason for hiding this comment

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

I suggest add if here, and we do not need to compare with the location string

    const countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/) || l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The length of the l variable may be equal to 1, so add the logic to judge the length.

const location = run.location_country;
  let [city, province, country] = ['', '', ''];
  if (location) {
    // Only for Chinese now
    const cityMatch = location.match(/[\u4e00-\u9fa5]*市/);
    const provinceMatch = location.match(/[\u4e00-\u9fa5]*省/);
    if (cityMatch) {
      [city] = cityMatch;
    }
    if (provinceMatch) {
      [province] = provinceMatch;
    }
    const l = location.split(',');
    // or to handle keep location format
    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;
    }
  }

@@ -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,
Copy link
Owner

@yihong0618 yihong0618 Oct 24, 2020

Choose a reason for hiding this comment

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

we need to get if verticalAccuracy attr first.
if there is no value here
We do not add it to the dict.
only keep the latitude, longitude, time in the dict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other props may not need to be judged to exist.

   # future to support heart rate
    points_dict_list = []
    for point in run_points_data:
        points_dict = {
            "latitude": point["latitude"],
            "longitude": point["longitude"],
            "time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000),
        }
        if "verticalAccuracy" in point.keys():
            points_dict["verticalAccuracy"] = point["verticalAccuracy"]
        points_dict_list.append(points_dict)
    gpx = gpxpy.gpx.GPX()

Copy link
Owner

Choose a reason for hiding this comment

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

  1. only in is fine
    image
  2. points_dict["elevation"] = point["verticalAccuracy"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll pr again.

@yihong0618
Copy link
Owner

yihong0618 commented Oct 24, 2020

@abinnz
Cool thanks a lot.
If you want you can share your page in #12

@yihong0618 yihong0618 merged commit f6c5058 into yihong0618:master Oct 24, 2020
yihong0618 added a commit that referenced this pull request Oct 27, 2020
修复同步keep数据出现的错误
yihong0618 added a commit that referenced this pull request Oct 27, 2020
修复同步keep数据出现的错误
yihong0618 added a commit that referenced this pull request Mar 23, 2021
修复同步keep数据出现的错误
ben-29 referenced this pull request in ben-29/workouts_page Sep 5, 2021
修复同步keep数据出现的错误
ben-29 referenced this pull request in ben-29/workouts_page Sep 5, 2021
修复同步keep数据出现的错误
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants