-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchallenge_tracker_examples.py
122 lines (109 loc) · 4.42 KB
/
challenge_tracker_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from otf_api import Otf
from otf_api.models.enums import ChallengeCategory, EquipmentType
def main():
otf = Otf()
# You can get challenges by equipment or by challenge category
for et in EquipmentType:
benchmarks = otf.get_benchmarks_by_equipment(et)
if not benchmarks:
continue
print(f"Equipment: {et.name}, Challenges: {len(benchmarks):,}")
for b in benchmarks:
print(f"{b.challenge_name} - {len(b.challenge_histories):,} entries")
print(b.model_dump_json(indent=4))
"""
{
"challenge_category_id": 17,
"challenge_sub_category_id": null,
"equipment_id": 4,
"equipment_name": "Rower",
"metric_entry": {
"title": "2000 METER",
"equipment_id": 4,
"entry_type": "Time",
"metric_key": "2000METER",
"min_value": "05:00.00",
"max_value": "25:00.00"
},
"challenge_name": "2000 METER Row",
"best_record": "10:49.48",
"last_record": "10:49.48",
"previous_record": "10:49.48",
"unit": null,
"goals": null,
"challenge_histories": [
{
"studio_name": "AnyTown OH - East",
"start_date": "2025-01-16T00:00:00",
"end_date": "2025-01-16T23:59:00",
"total_result": "00:10:49.48",
"is_finished": true,
"benchmark_histories": [
{
"studio_name": "AnyTown OH - East",
"equipment_id": 4,
"class_time": "2025-01-16T09:45:00",
"challenge_sub_category_id": null,
"weight_lbs": 0,
"class_name": "Orange 60 Min 2G",
"coach_name": "Coach Coach",
"result": "10:49.48"
}
]
}
]
}
"""
for ct in ChallengeCategory:
benchmarks = otf.get_benchmarks_by_challenge_category(ct)
if not benchmarks:
continue
print(f"Challenge Name: {ct.name}, Challenges: {len(benchmarks):,}")
for b in benchmarks:
print(f"{b.challenge_name} - {len(b.challenge_histories):,} entries")
print(b.model_dump_json(indent=4))
"""
{
"challenge_category_id": 55,
"challenge_sub_category_id": null,
"equipment_id": 4,
"equipment_name": "Rower",
"metric_entry": {
"title": "23 MIN",
"equipment_id": 4,
"entry_type": "Distance",
"metric_key": "23MIN",
"min_value": "",
"max_value": ""
},
"challenge_name": "Inferno",
"best_record": 2284.0,
"last_record": 2284.0,
"previous_record": 2284.0,
"unit": "m",
"goals": null,
"challenge_histories": [
{
"studio_name": "AnyTown OH - East",
"start_date": "2024-05-14T00:00:00",
"end_date": "2024-05-14T23:59:00",
"total_result": 2284.0,
"is_finished": true,
"benchmark_histories": [
{
"studio_name": "AnyTown OH - East",
"equipment_id": 4,
"class_time": "2024-05-14T09:45:00",
"challenge_sub_category_id": null,
"weight_lbs": 0,
"class_name": "Orange 60 Min 2G",
"coach_name": "Coach Coach",
"result": 2284.0
}
]
}
]
}
"""
if __name__ == "__main__":
main()