-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Richer activity title with more sport types and locations #733
Changes from 5 commits
d95b27a
7d27837
b1c436c
55b7bb9
d34f4d9
a3d0314
4b5bbdd
c86d040
d9ae3ac
bed31c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ def __init__(self): | |
self.file_names = [] | ||
self.polylines = [] | ||
self.polyline_str = "" | ||
self.track_name = None | ||
self.start_time = None | ||
self.end_time = None | ||
self.start_time_local = None | ||
|
@@ -52,6 +53,7 @@ def __init__(self): | |
self.run_id = 0 | ||
self.start_latlng = [] | ||
self.type = "Run" | ||
self.subtype = None # for fit file | ||
self.device = "" | ||
|
||
def load_gpx(self, file_name): | ||
|
@@ -190,6 +192,8 @@ def _load_gpx_data(self, gpx): | |
polyline_container = [] | ||
heart_rate_list = [] | ||
for t in gpx.tracks: | ||
if self.track_name is None: | ||
self.track_name = t.name | ||
for s in t.segments: | ||
try: | ||
extensions = [ | ||
|
@@ -246,7 +250,11 @@ def _load_fit_data(self, fit: dict): | |
self.average_heartrate = ( | ||
message["avg_heart_rate"] if "avg_heart_rate" in message else None | ||
) | ||
self.type = message["sport"].lower() | ||
if message["sport"].lower() == "running": | ||
self.type = "Run" | ||
else: | ||
self.type = message["sport"].lower() | ||
self.subtype = message["sub_sport"] if "sub_sport" in message else None | ||
|
||
# moving_dict | ||
self.moving_dict["distance"] = message["total_distance"] | ||
|
@@ -334,11 +342,10 @@ def to_namedtuple(self, run_from="gpx"): | |
d = { | ||
"id": self.run_id, | ||
"name": ( | ||
f"run from {run_from} by {self.device}" | ||
if self.device | ||
else f"run from {run_from}" | ||
self.track_name if self.track_name else "none" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the default value, can we use "" instead of "none"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additionally, for names already synced in the db, please include instructions in the readme on enabling the feature for all data, possibly with a SQL, to reset names to default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
no problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It works if I remove all the caches and regenerate the running page completely. I am trying resolving problems on updating synced activities. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
resolved in d9ae3ac |
||
), # maybe change later | ||
"type": "Run", # Run for now only support run for now maybe change later | ||
"type": self.type, | ||
"subtype": (self.subtype if self.subtype else "none"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in d9ae3ac |
||
"start_date": self.start_time.strftime("%Y-%m-%d %H:%M:%S"), | ||
"end": self.end_time.strftime("%Y-%m-%d %H:%M:%S"), | ||
"start_date_local": self.start_time_local.strftime("%Y-%m-%d %H:%M:%S"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new column is not present in the SQLite file if the user syncs before this pull request. Users may face difficulties adding this column manually, or else syncing will fail. Perhaps you should add instructions in the readme or include a script to assist users in doing this easily, as seen in this ref1 ref2. There might be a simpler solution that I'm unaware of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db checks whether the new column exists after commit c86d040. If any column defined in
class Activity
does not exist, it will add a new column in data.db.