Skip to content

Commit

Permalink
Merge branch 'yihong0618:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jujimeizuo committed Dec 15, 2023
2 parents 75c8618 + b432476 commit 5c08ece
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ RUN npm config set registry https://registry.npm.taobao.org \
FROM develop-py AS data
ARG app
ARG nike_refresh_token
ARG email
ARG password
ARG secret_string
ARG client_id
ARG client_secret
ARG refresh_token
Expand All @@ -39,9 +38,9 @@ RUN DUMMY=${DUMMY}; \
if [ "$app" = "NRC" ] ; then \
python3 run_page/nike_sync.py ${nike_refresh_token}; \
elif [ "$app" = "Garmin" ] ; then \
python3 run_page/garmin_sync.py ${email} ${password}; \
python3 run_page/garmin_sync.py ${secret_string} ; \
elif [ "$app" = "Garmin-CN" ] ; then \
python3 run_page/garmin_sync.py ${email} ${password} --is-cn ; \
python3 run_page/garmin_sync.py ${secret_string} --is-cn ; \
elif [ "$app" = "Strava" ] ; then \
python3 run_page/strava_sync.py ${client_id} ${client_secret} ${refresh_token};\
elif [ "$app" = "Nike_to_Strava" ] ; then \
Expand All @@ -60,5 +59,5 @@ COPY --from=data /root/running_page /root/running_page
RUN pnpm run build

FROM nginx:alpine AS web
COPY --from=frontend-build /root/running_page/public /usr/share/nginx/html/
COPY --from=frontend-build /root/running_page/dist /usr/share/nginx/html/
COPY --from=frontend-build /root/running_page/assets /usr/share/nginx/html/assets
15 changes: 7 additions & 8 deletions run_page/codoon_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def formated_input(
def tcx_output(fit_array, run_data):
# route ID
fit_id = str(run_data["id"])
# local time
fit_start_time_local = run_data["start_time"]
# zulu time
utc = adjust_time_to_utc(to_date(fit_start_time_local), str(get_localzone()))
fit_start_time = utc.strftime("%Y-%m-%dT%H:%M:%SZ")

# Root node
training_center_database = ET.Element(
"TrainingCenterDatabase",
Expand All @@ -154,7 +160,7 @@ def tcx_output(fit_array, run_data):
activities.append(activity)
# Id
activity_id = ET.Element("Id")
activity_id.text = fit_id
activity_id.text = fit_start_time # Codoon use start_time as ID
activity.append(activity_id)
# Creator
activity_creator = ET.Element("Creator")
Expand All @@ -164,13 +170,6 @@ def tcx_output(fit_array, run_data):
activity_creator_name.text = "咕咚"
activity_creator.append(activity_creator_name)
# Lap

# local time
fit_start_time_local = run_data["start_time"]
# zulu time
utc = adjust_time_to_utc(to_date(fit_start_time_local), str(get_localzone()))
fit_start_time = utc.strftime("%Y-%m-%dT%H:%M:%SZ")

activity_lap = ET.Element("Lap", {"StartTime": fit_start_time})
activity.append(activity_lap)
# TotalTimeSeconds
Expand Down
4 changes: 3 additions & 1 deletion run_page/gpxtrackposter/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ def load_from_db(self, activity):
self.start_time_local = start_time
self.end_time = start_time + activity.elapsed_time
self.length = float(activity.distance)
if not IGNORE_BEFORE_SAVING:
if IGNORE_BEFORE_SAVING:
summary_polyline = filter_out(activity.summary_polyline)
else:
summary_polyline = activity.summary_polyline
polyline_data = polyline.decode(summary_polyline) if summary_polyline else []
self.polylines = [[s2.LatLng.from_degrees(p[0], p[1]) for p in polyline_data]]
self.run_id = activity.run_id
Expand Down
4 changes: 3 additions & 1 deletion run_page/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def to_date(ts):
# shouldn't be an issue since it's an offline cmdline tool
return datetime.strptime(ts, ts_fmt)
except ValueError:
print("Error: Can not execute strptime")
print(
f"Warning: Can not execute strptime {ts} with ts_fmt {ts_fmt}, try next one..."
)
pass

raise ValueError(f"cannot parse timestamp {ts} into date with fmts: {ts_fmts}")
Expand Down
3 changes: 3 additions & 0 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const Index = () => {
func: (_run: Activity, _value: string) => boolean
) => {
scrollToMap();
if(name != 'Year'){
setYear(thisYear)
}
setActivity(filterAndSortRuns(activities, item, func, sortDateFunc));
setRunIndex(-1);
setTitle(`${item} ${name} Running Heatmap`);
Expand Down

0 comments on commit 5c08ece

Please sign in to comment.