Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
* upstream:
  doc: drop vercel cache build doc for newbie
  chore: merge example data
  fix: using session to download keep route
  feat: add a new runner's page (yihong0618#482)
  Add correction on instruction of build github pages. (yihong0618#476)
  fix: set gh page default to true for newbie.......
  Add sync strava data args comment: `--only-run` (yihong0618#471)
  fix: 同一天有多个运动时选中地图路线显示错误问题 (yihong0618#468)

# Conflicts:
#	README-CN.md
#	README.md
#	assets/github.svg
#	assets/github_2022.svg
#	assets/grid.svg
#	src/pages/index.jsx
  • Loading branch information
ben-29 committed Sep 16, 2023
2 parents f3a3588 + 3d5b8d9 commit 3fded5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/run_data_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ env:
IGNORE_RANGE: 0 # Unit meter
SAVE_DATA_IN_GITHUB_CACHE: false # if you deploy in the vercal, check the README
DATA_CACHE_PREFIX: "track_data"
BUILD_GH_PAGES: false
BUILD_GH_PAGES: true # If you do not need GitHub Page please set it to `false`

jobs:
sync:
Expand Down Expand Up @@ -101,6 +101,7 @@ jobs:
if: env.RUN_TYPE == 'strava'
run: |
python scripts/strava_sync.py ${{ secrets.STRAVA_CLIENT_ID }} ${{ secrets.STRAVA_CLIENT_SECRET }} ${{ secrets.STRAVA_CLIENT_REFRESH_TOKEN }}
# If you only want to sync `type running` add args --only-run, default script is to sync all data (rides and runs).
# python scripts/garmin_sync.py ${{ secrets.GARMIN_EMAIL }} ${{ secrets.GARMIN_PASSWORD }} --only-run --is-cn

- name: Run sync Codoon script
Expand Down
2 changes: 2 additions & 0 deletions assets/github_2023.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/year_2023.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions scripts/keep_sync.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import argparse
import base64
import json
import math
import os
import time
import zlib
import math
from collections import namedtuple
from datetime import datetime, timedelta

import eviltransform
import gpxpy
import polyline
import requests
import eviltransform
from config import GPX_FOLDER, JSON_FILE, SQL_FILE, run_map, start_point
from generator import Generator

from utils import adjust_time

# need to test
Expand Down Expand Up @@ -71,7 +70,9 @@ def decode_runmap_data(text):
return run_points_data


def parse_raw_data_to_nametuple(run_data, old_gpx_ids, with_download_gpx=False):
def parse_raw_data_to_nametuple(
run_data, old_gpx_ids, session, with_download_gpx=False
):
run_data = run_data["data"]
run_points_data = []

Expand All @@ -83,7 +84,7 @@ def parse_raw_data_to_nametuple(run_data, old_gpx_ids, with_download_gpx=False):
"rawDataURL"
):
raw_data_url = run_data.get("rawDataURL")
r = requests.get(raw_data_url)
r = session.get(raw_data_url)
# string strart with `H4sIAAAAAAAA` --> decode and unzip
run_points_data = decode_runmap_data(r.text)
run_points_data_gpx = run_points_data
Expand Down Expand Up @@ -158,7 +159,7 @@ def get_all_keep_tracks(email, password, old_tracks_ids, with_download_gpx=False
try:
run_data = get_single_run_data(s, headers, run)
track = parse_raw_data_to_nametuple(
run_data, old_gpx_ids, with_download_gpx
run_data, old_gpx_ids, s, with_download_gpx
)
tracks.append(track)
except Exception as e:
Expand Down
6 changes: 3 additions & 3 deletions src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
const Index = () => {
const { siteTitle } = useSiteMetadata();
const { activities, thisYear } = useActivities();
const [year, setYear] = useState('Total');
const [year, setYear] = useState(thisYear);
const [runIndex, setRunIndex] = useState(-1);
const [runs, setActivity] = useState(
filterAndSortRuns(activities, year, filterYearRuns, sortDateFunc)
Expand Down Expand Up @@ -131,7 +131,7 @@ const Index = () => {
if (target) {
const tagName = target.tagName.toLowerCase()

// 点击的是 github 样式 svg
// click the github-stat style svg
if (tagName === 'rect' &&
parseFloat(target.getAttribute('width')) === 2.6 &&
parseFloat(target.getAttribute('height')) === 2.6 &&
Expand All @@ -144,7 +144,7 @@ const Index = () => {
}
locateActivity(runIDsOnDate)

} else if (tagName === 'polyline') { // 点击的是路线缩略图
} else if (tagName === 'polyline') { // click the route grid svg
const desc = target.getElementsByTagName('desc')[0]
if (!desc) { return }
const run_id = Number(desc.innerHTML)
Expand Down

0 comments on commit 3fded5e

Please sign in to comment.