Access of acvtivity objects from GC.activities with python

354 views
Skip to first unread message

M Thomas

unread,
Sep 5, 2023, 2:40:34 AM9/5/23
to golden-cheetah-users
Hi,

I would like to set metadate for rides using python but do not get access to the objects.
 
In trends view getting the metadata of selected activity is fine with:

activity = GC.activity()

equipment = GC.activityMetrics()['Equipment']


How to get the activity object for each of the activities defined. That code does not work as the result is from type date:

actDates = GC.activities(filter = 'Equipment contains "Topstone" and Date >= "2023/01/01"')


for date in actDates:

            rides = GC.activity(activity=date)

            print(list(rides))

            for r in rides:

                   metrics=GC.activityMetrics() # here only the selected activity is accessable

                   # how to get access of the metadata of activity?


I would also like to know how we can count and sum the duration of activities after a certain activity with metadata tag "MaintenanceDone". Target is, not to write the maintanance tags in every activity but rather set a special activitiy called Maintenance and do the calculations from that.


Best, 

Maik



marcen

unread,
Sep 5, 2023, 6:37:53 AM9/5/23
to golden-cheetah-users
You can also use filter/search box in GC to set Metadata Fields.

For Equipment tracking.

I have create a tab in activites -> details -> Equipment
One metadata field is Bikes. Here set the bike you wount to track. Then you can use filter in the charts.
The next metadata fields are for equipment that you want to track. With every maintenance you set the keyword.
Screenshot_20230905_105752.png

Next step create a overview chart in trends view.
Then create a tile table and use a while loop and a if block for computer the metrics.
Set the filter what bike you want to track.
Keyword: you set in the metadata field
Component: which component you want to tracked
Further down the current component value is stored. In a KPI tile the stored value is fetched.
Screenshot_20230905_120533.png
Screenshot_20230905_122103.png

Finished it looks like this.
Screenshot_20230905_122810.png
Equipment.gchart

M Thomas

unread,
Sep 5, 2023, 6:45:52 AM9/5/23
to golden-cheetah-users
Hi, this is also a good approach and similar to the one described here: https://groups.google.com/g/golden-cheetah-users/c/T7vYxDVaiF4/m/BjqFPXMPAwAJ
Thank you for sharing.

Ale Martinez

unread,
Sep 5, 2023, 11:59:50 AM9/5/23
to golden-cheetah-users
From a Python chart you can use seasonMetrics for that computation, but if you want to set metadata fields from Python, you need to use a Custom Data Processor, there are specific APIs for that purpose (setTag et. al.).  

Peter K

unread,
Sep 8, 2023, 9:45:00 AM9/8/23
to golden-cheetah-users
Marcen's approach is similar to the one described here, However, if I understand it correctly, it minimizes the administration needed to keep track of the usage for each component. After creating the maintenance page of metadata, you don't have to tag each activity with a specific keyword, only the ones that maintenance was performed. The table summarizes the metrics you want for the activities in each maintenance period in one row and the KPI displays the current running total for the component. 

Looking at the screenshot above, I'm assuming that Marcen has a second metadata field for each component's model that can be used to create historical charts to compare different models of the same component. 

Thanks again for sharing Marcen. If you have worked out any historical charts, I'd be very interested in seeing them.

Peter

marcen

unread,
Sep 8, 2023, 4:59:56 PM9/8/23
to golden-cheetah-users
Yes, this is right. 
> However, if I understand it correctly, it minimizes the administration needed to keep track of the usage for each component. After creating the maintenance page of metadata, you don't have to tag each activity with a specific keyword, only the ones that maintenance was performed.

You have only set you'r bikes in all aktivities. This job can done . https://github.com/GoldenCheetah/GoldenCheetah/wiki/UG_Preferences_Data-Fields#defaults
Screenshot_20230908_183335.png

Yes, table shows maintenance period in one row. The KPI shows the maintenance period in progress. You do an new ride km and other metrics are counted to the KPI. The bar can be used to show the next maintenance.
Screenshot_20230905_122810.png

Had talked to Maik about the filter, what is also possible is to create a filter for the bikes in the side bar and use only one equipment chart for the different bikes.

historical charts - I am not sure how this should look exactly.
Do you mean a scatter or lines chart over time?
I have attached a chart.
Equipment.gchart
Tires.gchart

Peter K

unread,
Sep 10, 2023, 9:12:18 AM9/10/23
to golden-cheetah-users
Thanks Marcen. I think the tires chart could work. I was looking for a bar chart that will show the distance or duration of the same type of component. In you graph, each bar will be the distance for each model of each front tire model I've used on the bike over the years I own the bike.

I'm also working on a variation of your table chart to show segment information. I'm able to list all the segments based on your last suggestion with the index. What I'd like to do is build a table with 3 rows for a specific segment, best duration, average duration and worse duration. Is there a way to see any debug output while you are working in these tiles?

Ale Martinez

unread,
Sep 10, 2023, 3:47:50 PM9/10/23
to golden-cheetah-users
El domingo, 10 de septiembre de 2023 a la(s) 10:12:18 UTC-3, Peter K escribió:
Is there a way to see any debug output while you are working in these tiles?

RTFM S16E12

marcen

unread,
Sep 10, 2023, 6:03:51 PM9/10/23
to golden-cheetah-users

Both charts sound interesting. I haven't worked on anything like that. The idea for me was to track the mileage of a component.

I have not seen a debug function for the tiles yet.

Peter K

unread,
Sep 11, 2023, 9:59:15 AM9/11/23
to golden-cheetah-users
Thanks Marcen. Would you mind posting a picture of all the tiles in your chart?  Loading the chart without the metadata and trying to translate from German to English, makes it difficult to visualize the output. 

marcen

unread,
Sep 11, 2023, 11:42:13 AM9/11/23
to golden-cheetah-users
Here are the pictures of the complete chart.Screenshot_20230911_173233.pngScreenshot_20230911_173417.png

Peter K

unread,
Sep 12, 2023, 11:47:59 AM9/12/23
to golden-cheetah-users
Thank you!
Reply all
Reply to author
Forward
0 new messages