Skip to content

Commit

Permalink
fix: Codoon tcx output use start_time as ID instead of Codoon id (#568)
Browse files Browse the repository at this point in the history
* fix: Codoon tcv output use start_time as ID instead of Codoon id

* fix lint by black

---------

Co-authored-by: anchao <chao.an@fastonetech.com>
  • Loading branch information
anChaOs and anchao authored Dec 12, 2023
1 parent b2007b5 commit b432476
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
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 comment on commit b432476

@vercel
Copy link

@vercel vercel bot commented on b432476 Dec 12, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

running-page – ./

running-page-yihong0618.vercel.app
running-page-git-master-yihong0618.vercel.app
running-page.vercel.app

Please sign in to comment.