Skip to content

Commit

Permalink
Merge branch 'upstream'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README-CN.md
#	README.md
#	src/components/RunMap/index.tsx
#	src/components/RunTable/RunRow.tsx
#	src/components/SVGStat/index.tsx
#	src/components/YearsStat/index.tsx
#	src/pages/index.tsx
  • Loading branch information
ben-29 committed Dec 25, 2023
2 parents 2e8a080 + 6d7bd29 commit d8fb240
Show file tree
Hide file tree
Showing 31 changed files with 332 additions and 81 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:prettier/recommended',
],
overrides: [],
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,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
1 change: 1 addition & 0 deletions assets/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const yearStats = import.meta.glob('./year_*.svg', { import: 'ReactComponent' })
export const totalStat = import.meta.glob(['./github.svg', './grid.svg'], { import: 'ReactComponent' })
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"@mapbox/mapbox-gl-language": "^1.0.0",
"@mapbox/polyline": "^1.1.1",
"@svgr/plugin-svgo": "^8.1.0",
"@vercel/analytics": "^0.1.6",
"@vitejs/plugin-react": "^4.0.0",
"gcoord": "^0.3.2",
Expand All @@ -14,6 +15,7 @@
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga4": "^2.1.0",
"react-helmet-async": "^1.3.0",
"react-map-gl": "^7.1.6",
"react-router-dom": "^6.15.0",
Expand Down
134 changes: 134 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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/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
1 change: 0 additions & 1 deletion src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Link } from 'react-router-dom';
import React from 'react';
import useSiteMetadata from '@/hooks/useSiteMetadata';

const Header = () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/LocationStat/CitiesStat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Stat from '@/components/Stat';
import useActivities from '@/hooks/useActivities';

Expand Down
1 change: 0 additions & 1 deletion src/components/LocationStat/LocationSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Stat from '@/components/Stat';
import useActivities from '@/hooks/useActivities';

Expand Down
1 change: 0 additions & 1 deletion src/components/LocationStat/PeriodStat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Stat from '@/components/Stat';
import useActivities from '@/hooks/useActivities';
import { IS_CHINESE } from '@/utils/const';
Expand Down
1 change: 0 additions & 1 deletion src/components/LocationStat/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import YearStat from '@/components/YearStat';
import {
CHINESE_LOCATION_INFO_MESSAGE_FIRST,
Expand Down
1 change: 0 additions & 1 deletion src/components/RunMap/RunMapButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import useActivities from '@/hooks/useActivities';
import styles from './style.module.scss';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ReactComponent as EndSvg } from '@assets/end.svg';
import { ReactComponent as StartSvg } from '@assets/start.svg';
import React from 'react';
import { Marker } from 'react-map-gl';
import styles from './style.module.scss';

Expand Down
6 changes: 3 additions & 3 deletions src/components/RunMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
MAP_HEIGHT,
} from '@/utils/const';
import { Coordinate, IViewState, geoJsonForMap } from '@/utils/utils';
import RunMarker from './RunMaker';
import RunMarker from './RunMarker';
import RunMapButtons from './RunMapButtons';
import styles from './style.module.scss';
import { FeatureCollection } from 'geojson';
Expand Down Expand Up @@ -110,7 +110,7 @@ const RunMap = ({
[endLon, endLat] = points[points.length - 1];
}
let dash = USE_DASH_LINE && !isSingleRun && !isBigMap ? [2, 2] : [2, 0];
const onMove = React.useCallback(({ viewState }: {viewState: IViewState}) => {
const onMove = React.useCallback(({ viewState }: { viewState: IViewState }) => {
setViewState(viewState);
}, []);
const style: React.CSSProperties = {
Expand All @@ -126,7 +126,7 @@ const RunMap = ({

return (
<Map
{ ...viewState }
{...viewState}
onMove={onMove}
style={style}
mapStyle="mapbox://styles/mapbox/dark-v10"
Expand Down
1 change: 0 additions & 1 deletion src/components/RunTable/RunRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { formatPace, colorFromType, formatRunTime, Activity, RunIds } from '@/utils/utils';
import styles from './style.module.scss';

Expand Down
4 changes: 2 additions & 2 deletions src/components/RunTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const RunTable = ({
: b.average_speed - a.average_speed;
const sortBPMFunc: SortFunc = (a, b) => {
return sortFuncInfo === 'BPM'
? a.average_heartrate ?? 0 - (b.average_heartrate ?? 0)
: b.average_heartrate ?? 0 - (a.average_heartrate ?? 0);
? (a.average_heartrate ?? 0) - (b.average_heartrate ?? 0)
: (b.average_heartrate ?? 0) - (a.average_heartrate ?? 0);
};
const sortRunTimeFunc: SortFunc = (a, b) => {
const aTotalSeconds = convertMovingTime2Sec(a.moving_time);
Expand Down
Loading

0 comments on commit d8fb240

Please sign in to comment.