hpde-analytics-cli 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hpde_analytics_cli-1.0.0/LICENSE +21 -0
- hpde_analytics_cli-1.0.0/PKG-INFO +309 -0
- hpde_analytics_cli-1.0.0/README.md +267 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/__init__.py +4 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/api/__init__.py +1 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/api/client.py +325 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/auth/__init__.py +1 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/auth/credentials.py +256 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/auth/oauth.py +529 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/main.py +360 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/utils/__init__.py +1 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/utils/data_export.py +366 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/utils/field_discovery.py +351 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli/utils/report_generator.py +459 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/PKG-INFO +309 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/SOURCES.txt +25 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/dependency_links.txt +1 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/entry_points.txt +2 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/requires.txt +15 -0
- hpde_analytics_cli-1.0.0/hpde_analytics_cli.egg-info/top_level.txt +1 -0
- hpde_analytics_cli-1.0.0/pyproject.toml +95 -0
- hpde_analytics_cli-1.0.0/setup.cfg +4 -0
- hpde_analytics_cli-1.0.0/tests/test_client.py +324 -0
- hpde_analytics_cli-1.0.0/tests/test_credentials.py +224 -0
- hpde_analytics_cli-1.0.0/tests/test_data_export.py +328 -0
- hpde_analytics_cli-1.0.0/tests/test_main.py +274 -0
- hpde_analytics_cli-1.0.0/tests/test_report_generator.py +415 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kevin Homan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hpde-analytics-cli
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Data analysis and reporting tool for HPDE and Time Trials programs
|
|
5
|
+
Author-email: Kevin Homan <homan13@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Homan13/hpde-analytics-cli
|
|
8
|
+
Project-URL: Documentation, https://github.com/Homan13/hpde-analytics-cli#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Homan13/hpde-analytics-cli.git
|
|
10
|
+
Project-URL: Issues, https://github.com/Homan13/hpde-analytics-cli/issues
|
|
11
|
+
Keywords: motorsports,hpde,time-trials,motorsportreg,analytics,reporting
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: requests>=2.28.0
|
|
28
|
+
Requires-Dist: requests-oauthlib>=1.3.0
|
|
29
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
30
|
+
Requires-Dist: openpyxl>=3.1.0
|
|
31
|
+
Requires-Dist: keyring>=24.0.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
39
|
+
Requires-Dist: bandit>=1.7.0; extra == "dev"
|
|
40
|
+
Requires-Dist: safety>=2.3.0; extra == "dev"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# HPDE Analytics CLI
|
|
44
|
+
|
|
45
|
+
[](https://github.com/Homan13/hpde-analytics-cli/actions/workflows/ci.yml)
|
|
46
|
+
[](https://pypi.org/project/hpde-analytics-cli/)
|
|
47
|
+
[](https://opensource.org/licenses/MIT)
|
|
48
|
+
|
|
49
|
+
Data analysis and reporting tool that allows a user to connect to the MotorsportsReg (MSR) API to export data and create reports. This tool automates the extraction of event registration data from MSR and generates Excel reports for High Performance Drivers Education (HPDE) and Time Trials program analytics.
|
|
50
|
+
|
|
51
|
+
## Getting Started
|
|
52
|
+
|
|
53
|
+
These instructions will help you set up the project on your local machine for development and usage.
|
|
54
|
+
|
|
55
|
+
### Prerequisites
|
|
56
|
+
|
|
57
|
+
- Python 3.8 or higher
|
|
58
|
+
- MotorsportsReg OAuth consumer credentials
|
|
59
|
+
- pip (Python package installer)
|
|
60
|
+
|
|
61
|
+
### Installation
|
|
62
|
+
|
|
63
|
+
#### Option 1: Install from PyPI (Recommended)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install hpde-analytics-cli
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Option 2: Install from source
|
|
70
|
+
|
|
71
|
+
1. Clone the repository:
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/Homan13/hpde-analytics-cli.git
|
|
74
|
+
cd hpde-analytics-cli
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
2. Install the package:
|
|
78
|
+
```bash
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Configuration
|
|
83
|
+
|
|
84
|
+
1. Configure your credentials (choose one method):
|
|
85
|
+
|
|
86
|
+
**Option A: Secure storage (Recommended)**
|
|
87
|
+
```bash
|
|
88
|
+
hpde-analytics-cli --configure
|
|
89
|
+
```
|
|
90
|
+
This stores your credentials securely in your system's keyring (macOS Keychain, Windows Credential Locker, or Linux Secret Service).
|
|
91
|
+
|
|
92
|
+
**Option B: Environment file (Fallback)**
|
|
93
|
+
```bash
|
|
94
|
+
cp .env.example .env
|
|
95
|
+
```
|
|
96
|
+
Edit `.env` and add your MotorsportsReg OAuth credentials:
|
|
97
|
+
```
|
|
98
|
+
MSR_CONSUMER_KEY=your_consumer_key_here
|
|
99
|
+
MSR_CONSUMER_SECRET=your_consumer_secret_here
|
|
100
|
+
MSR_BASE_URL=https://api.motorsportreg.com
|
|
101
|
+
MSR_CALLBACK_PORT=8089
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
2. Check credential status (optional):
|
|
105
|
+
```bash
|
|
106
|
+
hpde-analytics-cli --credential-status
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
3. Run initial authentication:
|
|
110
|
+
```bash
|
|
111
|
+
hpde-analytics-cli --auth
|
|
112
|
+
```
|
|
113
|
+
Follow the browser prompts to authorize the application.
|
|
114
|
+
|
|
115
|
+
## Usage
|
|
116
|
+
|
|
117
|
+
### Export Event Data
|
|
118
|
+
|
|
119
|
+
Export all event registration data (both raw and filtered formats):
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
hpde-analytics-cli --export \
|
|
123
|
+
--org-id 11A1AAAA-2B2B-C333-4D4444444D4DD44D \
|
|
124
|
+
--event-id <EVENT_ID> \
|
|
125
|
+
--name HPDE_TT_1_2025
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `--org-id`: MSR organization ID (required)
|
|
130
|
+
- `--event-id`: MSR event ID (required)
|
|
131
|
+
- `--name`: Custom name for export folder (optional)
|
|
132
|
+
- `--output-dir`: Custom output directory (optional, defaults to `output/`)
|
|
133
|
+
|
|
134
|
+
### Generate Time Trials Report
|
|
135
|
+
|
|
136
|
+
Generate an Excel report from exported data:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
hpde-analytics-cli --report \
|
|
140
|
+
--export-dir output/HPDE_TT_1_2025_20260110_123456 \
|
|
141
|
+
--name HPDE_TT_1_2025
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Parameters:**
|
|
145
|
+
- `--export-dir`: Path to exported data folder (required)
|
|
146
|
+
- `--name`: Custom name for report file (optional)
|
|
147
|
+
- `--report-file`: Specific output path for report (optional)
|
|
148
|
+
|
|
149
|
+
### Other Commands
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Configure or update API credentials (secure keyring storage)
|
|
153
|
+
hpde-analytics-cli --configure
|
|
154
|
+
|
|
155
|
+
# Check credential configuration status
|
|
156
|
+
hpde-analytics-cli --credential-status
|
|
157
|
+
|
|
158
|
+
# Re-authenticate if tokens expire
|
|
159
|
+
hpde-analytics-cli --auth
|
|
160
|
+
|
|
161
|
+
# Run field discovery to explore available data
|
|
162
|
+
hpde-analytics-cli --discover \
|
|
163
|
+
--org-id <ORG_ID> \
|
|
164
|
+
--event-id <EVENT_ID>
|
|
165
|
+
|
|
166
|
+
# Show all available options
|
|
167
|
+
hpde-analytics-cli --help
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Report Features
|
|
171
|
+
|
|
172
|
+
The generated Time Trials report includes:
|
|
173
|
+
|
|
174
|
+
- **Driver Information**: Name, email, member ID
|
|
175
|
+
- **Vehicle Details**: Year/make/model (combined), color, tire brand, vehicle number
|
|
176
|
+
- **Classification**: TT class and class grouping (Max, Sport, Tuner, Unlimited)
|
|
177
|
+
- **Participation Tracking**:
|
|
178
|
+
- Days attended (Friday/Saturday/Sunday/combinations)
|
|
179
|
+
- Day count (1 Day, 2 Days, 3 Days)
|
|
180
|
+
- Instructor status (Yes/No)
|
|
181
|
+
- AYCE participation (Time Trials + Advanced HPDE)
|
|
182
|
+
- Participation type (TT Only, TT + Instructor, TT + AYCE, TT + Instructor + AYCE)
|
|
183
|
+
|
|
184
|
+
**Pivot-Ready Columns**: Class Group, Day Count, and Participation Type columns are optimized for Excel pivot table analysis to track registration trends.
|
|
185
|
+
|
|
186
|
+
## Project Structure
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
hpde-analytics-cli/
|
|
190
|
+
├── .env.example # Credential template
|
|
191
|
+
├── .gitignore # Git exclusions
|
|
192
|
+
├── pyproject.toml # Package configuration
|
|
193
|
+
├── README.md # This file
|
|
194
|
+
├── hpde_analytics_cli/
|
|
195
|
+
│ ├── __init__.py
|
|
196
|
+
│ ├── main.py # CLI entry point
|
|
197
|
+
│ ├── auth/
|
|
198
|
+
│ │ ├── __init__.py
|
|
199
|
+
│ │ ├── credentials.py # Secure credential management
|
|
200
|
+
│ │ └── oauth.py # OAuth 1.0a authentication
|
|
201
|
+
│ ├── api/
|
|
202
|
+
│ │ ├── __init__.py
|
|
203
|
+
│ │ └── client.py # MSR API client
|
|
204
|
+
│ └── utils/
|
|
205
|
+
│ ├── __init__.py
|
|
206
|
+
│ ├── data_export.py # Data export to JSON/CSV
|
|
207
|
+
│ ├── field_discovery.py # API field enumeration
|
|
208
|
+
│ └── report_generator.py # Excel report generation
|
|
209
|
+
├── output/ # Export and report output (not in version control)
|
|
210
|
+
├── tokens/ # OAuth access tokens (not in version control)
|
|
211
|
+
└── tests/ # Unit tests
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Export Structure
|
|
215
|
+
|
|
216
|
+
Each export creates two data sets:
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
HPDE_TT_1_2025_20260110_123456/
|
|
220
|
+
├── raw_data/ # Complete API responses (for reference)
|
|
221
|
+
│ ├── profile_full.json
|
|
222
|
+
│ ├── calendar_full.json
|
|
223
|
+
│ ├── calendar_full.csv
|
|
224
|
+
│ ├── entrylist_full.json
|
|
225
|
+
│ ├── entrylist_full.csv
|
|
226
|
+
│ ├── attendees_full.json
|
|
227
|
+
│ ├── attendees_full.csv
|
|
228
|
+
│ ├── assignments_full.json
|
|
229
|
+
│ └── assignments_full.csv
|
|
230
|
+
├── profile.json # Filtered data for Time Trials
|
|
231
|
+
├── calendar.json
|
|
232
|
+
├── entrylist.json
|
|
233
|
+
├── entrylist.csv
|
|
234
|
+
├── attendees.json
|
|
235
|
+
├── attendees.csv
|
|
236
|
+
├── assignments.json
|
|
237
|
+
├── assignments.csv
|
|
238
|
+
└── export_summary.json
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Running the tests
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Install development dependencies
|
|
245
|
+
pip install -e ".[dev]"
|
|
246
|
+
|
|
247
|
+
# Run tests with coverage
|
|
248
|
+
pytest
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Deployment
|
|
252
|
+
|
|
253
|
+
This is a command-line tool designed to run locally. No deployment infrastructure is required.
|
|
254
|
+
|
|
255
|
+
**For scheduled/automated execution:**
|
|
256
|
+
- Consider setting up cron jobs (Linux/Mac) or Task Scheduler (Windows)
|
|
257
|
+
- Ensure OAuth tokens are refreshed as needed
|
|
258
|
+
- Store reports in a centralized location for team access
|
|
259
|
+
|
|
260
|
+
## Built With
|
|
261
|
+
|
|
262
|
+
* [Python 3](https://www.python.org/) - Programming language
|
|
263
|
+
* [requests](https://requests.readthedocs.io/) - HTTP library
|
|
264
|
+
* [requests-oauthlib](https://requests-oauthlib.readthedocs.io/) - OAuth 1.0a support
|
|
265
|
+
* [python-dotenv](https://pypi.org/project/python-dotenv/) - Environment variable management
|
|
266
|
+
* [openpyxl](https://openpyxl.readthedocs.io/) - Excel file generation
|
|
267
|
+
* [keyring](https://pypi.org/project/keyring/) - Secure credential storage
|
|
268
|
+
* [MotorsportsReg API](https://www.motorsportreg.com/) - Event registration data source
|
|
269
|
+
|
|
270
|
+
## Contributing
|
|
271
|
+
|
|
272
|
+
_In Progress - Contribution guidelines to be developed_
|
|
273
|
+
|
|
274
|
+
## Versioning
|
|
275
|
+
|
|
276
|
+
This project uses [Semantic Versioning (SemVer)](https://semver.org/):
|
|
277
|
+
- **MAJOR** version for incompatible API changes
|
|
278
|
+
- **MINOR** version for new functionality in a backward compatible manner
|
|
279
|
+
- **PATCH** version for backward compatible bug fixes
|
|
280
|
+
|
|
281
|
+
**Current Version:** 1.0.0
|
|
282
|
+
|
|
283
|
+
## Authors
|
|
284
|
+
|
|
285
|
+
* **Kevin Homan** - *Initial work and project lead* - WDCR Time Trials Chief Competition Director
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
290
|
+
|
|
291
|
+
## Acknowledgments
|
|
292
|
+
|
|
293
|
+
* SCCA Washington DC Region for supporting the Time Trials program
|
|
294
|
+
* MotorsportsReg.com for providing API access
|
|
295
|
+
* WDCR HPDE program for combined event management
|
|
296
|
+
|
|
297
|
+
## Security Notes
|
|
298
|
+
|
|
299
|
+
**Important:**
|
|
300
|
+
- Never commit `.env` or `tokens/` directory to version control
|
|
301
|
+
- OAuth consumer secrets and access tokens must be kept confidential
|
|
302
|
+
- The `.gitignore` file is configured to exclude these sensitive files automatically
|
|
303
|
+
- Use `hpde-analytics-cli --configure` to store credentials securely in your system keyring
|
|
304
|
+
|
|
305
|
+
## Support
|
|
306
|
+
|
|
307
|
+
For issues or questions related to this tool, contact the WDCR Time Trials administration.
|
|
308
|
+
|
|
309
|
+
For MotorsportsReg API issues, refer to the [MotorsportsReg API documentation](https://www.motorsportreg.com/).
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# HPDE Analytics CLI
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Homan13/hpde-analytics-cli/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/hpde-analytics-cli/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Data analysis and reporting tool that allows a user to connect to the MotorsportsReg (MSR) API to export data and create reports. This tool automates the extraction of event registration data from MSR and generates Excel reports for High Performance Drivers Education (HPDE) and Time Trials program analytics.
|
|
8
|
+
|
|
9
|
+
## Getting Started
|
|
10
|
+
|
|
11
|
+
These instructions will help you set up the project on your local machine for development and usage.
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
|
|
15
|
+
- Python 3.8 or higher
|
|
16
|
+
- MotorsportsReg OAuth consumer credentials
|
|
17
|
+
- pip (Python package installer)
|
|
18
|
+
|
|
19
|
+
### Installation
|
|
20
|
+
|
|
21
|
+
#### Option 1: Install from PyPI (Recommended)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install hpde-analytics-cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
#### Option 2: Install from source
|
|
28
|
+
|
|
29
|
+
1. Clone the repository:
|
|
30
|
+
```bash
|
|
31
|
+
git clone https://github.com/Homan13/hpde-analytics-cli.git
|
|
32
|
+
cd hpde-analytics-cli
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. Install the package:
|
|
36
|
+
```bash
|
|
37
|
+
pip install -e .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Configuration
|
|
41
|
+
|
|
42
|
+
1. Configure your credentials (choose one method):
|
|
43
|
+
|
|
44
|
+
**Option A: Secure storage (Recommended)**
|
|
45
|
+
```bash
|
|
46
|
+
hpde-analytics-cli --configure
|
|
47
|
+
```
|
|
48
|
+
This stores your credentials securely in your system's keyring (macOS Keychain, Windows Credential Locker, or Linux Secret Service).
|
|
49
|
+
|
|
50
|
+
**Option B: Environment file (Fallback)**
|
|
51
|
+
```bash
|
|
52
|
+
cp .env.example .env
|
|
53
|
+
```
|
|
54
|
+
Edit `.env` and add your MotorsportsReg OAuth credentials:
|
|
55
|
+
```
|
|
56
|
+
MSR_CONSUMER_KEY=your_consumer_key_here
|
|
57
|
+
MSR_CONSUMER_SECRET=your_consumer_secret_here
|
|
58
|
+
MSR_BASE_URL=https://api.motorsportreg.com
|
|
59
|
+
MSR_CALLBACK_PORT=8089
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. Check credential status (optional):
|
|
63
|
+
```bash
|
|
64
|
+
hpde-analytics-cli --credential-status
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
3. Run initial authentication:
|
|
68
|
+
```bash
|
|
69
|
+
hpde-analytics-cli --auth
|
|
70
|
+
```
|
|
71
|
+
Follow the browser prompts to authorize the application.
|
|
72
|
+
|
|
73
|
+
## Usage
|
|
74
|
+
|
|
75
|
+
### Export Event Data
|
|
76
|
+
|
|
77
|
+
Export all event registration data (both raw and filtered formats):
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
hpde-analytics-cli --export \
|
|
81
|
+
--org-id 11A1AAAA-2B2B-C333-4D4444444D4DD44D \
|
|
82
|
+
--event-id <EVENT_ID> \
|
|
83
|
+
--name HPDE_TT_1_2025
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Parameters:**
|
|
87
|
+
- `--org-id`: MSR organization ID (required)
|
|
88
|
+
- `--event-id`: MSR event ID (required)
|
|
89
|
+
- `--name`: Custom name for export folder (optional)
|
|
90
|
+
- `--output-dir`: Custom output directory (optional, defaults to `output/`)
|
|
91
|
+
|
|
92
|
+
### Generate Time Trials Report
|
|
93
|
+
|
|
94
|
+
Generate an Excel report from exported data:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
hpde-analytics-cli --report \
|
|
98
|
+
--export-dir output/HPDE_TT_1_2025_20260110_123456 \
|
|
99
|
+
--name HPDE_TT_1_2025
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Parameters:**
|
|
103
|
+
- `--export-dir`: Path to exported data folder (required)
|
|
104
|
+
- `--name`: Custom name for report file (optional)
|
|
105
|
+
- `--report-file`: Specific output path for report (optional)
|
|
106
|
+
|
|
107
|
+
### Other Commands
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Configure or update API credentials (secure keyring storage)
|
|
111
|
+
hpde-analytics-cli --configure
|
|
112
|
+
|
|
113
|
+
# Check credential configuration status
|
|
114
|
+
hpde-analytics-cli --credential-status
|
|
115
|
+
|
|
116
|
+
# Re-authenticate if tokens expire
|
|
117
|
+
hpde-analytics-cli --auth
|
|
118
|
+
|
|
119
|
+
# Run field discovery to explore available data
|
|
120
|
+
hpde-analytics-cli --discover \
|
|
121
|
+
--org-id <ORG_ID> \
|
|
122
|
+
--event-id <EVENT_ID>
|
|
123
|
+
|
|
124
|
+
# Show all available options
|
|
125
|
+
hpde-analytics-cli --help
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Report Features
|
|
129
|
+
|
|
130
|
+
The generated Time Trials report includes:
|
|
131
|
+
|
|
132
|
+
- **Driver Information**: Name, email, member ID
|
|
133
|
+
- **Vehicle Details**: Year/make/model (combined), color, tire brand, vehicle number
|
|
134
|
+
- **Classification**: TT class and class grouping (Max, Sport, Tuner, Unlimited)
|
|
135
|
+
- **Participation Tracking**:
|
|
136
|
+
- Days attended (Friday/Saturday/Sunday/combinations)
|
|
137
|
+
- Day count (1 Day, 2 Days, 3 Days)
|
|
138
|
+
- Instructor status (Yes/No)
|
|
139
|
+
- AYCE participation (Time Trials + Advanced HPDE)
|
|
140
|
+
- Participation type (TT Only, TT + Instructor, TT + AYCE, TT + Instructor + AYCE)
|
|
141
|
+
|
|
142
|
+
**Pivot-Ready Columns**: Class Group, Day Count, and Participation Type columns are optimized for Excel pivot table analysis to track registration trends.
|
|
143
|
+
|
|
144
|
+
## Project Structure
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
hpde-analytics-cli/
|
|
148
|
+
├── .env.example # Credential template
|
|
149
|
+
├── .gitignore # Git exclusions
|
|
150
|
+
├── pyproject.toml # Package configuration
|
|
151
|
+
├── README.md # This file
|
|
152
|
+
├── hpde_analytics_cli/
|
|
153
|
+
│ ├── __init__.py
|
|
154
|
+
│ ├── main.py # CLI entry point
|
|
155
|
+
│ ├── auth/
|
|
156
|
+
│ │ ├── __init__.py
|
|
157
|
+
│ │ ├── credentials.py # Secure credential management
|
|
158
|
+
│ │ └── oauth.py # OAuth 1.0a authentication
|
|
159
|
+
│ ├── api/
|
|
160
|
+
│ │ ├── __init__.py
|
|
161
|
+
│ │ └── client.py # MSR API client
|
|
162
|
+
│ └── utils/
|
|
163
|
+
│ ├── __init__.py
|
|
164
|
+
│ ├── data_export.py # Data export to JSON/CSV
|
|
165
|
+
│ ├── field_discovery.py # API field enumeration
|
|
166
|
+
│ └── report_generator.py # Excel report generation
|
|
167
|
+
├── output/ # Export and report output (not in version control)
|
|
168
|
+
├── tokens/ # OAuth access tokens (not in version control)
|
|
169
|
+
└── tests/ # Unit tests
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Export Structure
|
|
173
|
+
|
|
174
|
+
Each export creates two data sets:
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
HPDE_TT_1_2025_20260110_123456/
|
|
178
|
+
├── raw_data/ # Complete API responses (for reference)
|
|
179
|
+
│ ├── profile_full.json
|
|
180
|
+
│ ├── calendar_full.json
|
|
181
|
+
│ ├── calendar_full.csv
|
|
182
|
+
│ ├── entrylist_full.json
|
|
183
|
+
│ ├── entrylist_full.csv
|
|
184
|
+
│ ├── attendees_full.json
|
|
185
|
+
│ ├── attendees_full.csv
|
|
186
|
+
│ ├── assignments_full.json
|
|
187
|
+
│ └── assignments_full.csv
|
|
188
|
+
├── profile.json # Filtered data for Time Trials
|
|
189
|
+
├── calendar.json
|
|
190
|
+
├── entrylist.json
|
|
191
|
+
├── entrylist.csv
|
|
192
|
+
├── attendees.json
|
|
193
|
+
├── attendees.csv
|
|
194
|
+
├── assignments.json
|
|
195
|
+
├── assignments.csv
|
|
196
|
+
└── export_summary.json
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Running the tests
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Install development dependencies
|
|
203
|
+
pip install -e ".[dev]"
|
|
204
|
+
|
|
205
|
+
# Run tests with coverage
|
|
206
|
+
pytest
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Deployment
|
|
210
|
+
|
|
211
|
+
This is a command-line tool designed to run locally. No deployment infrastructure is required.
|
|
212
|
+
|
|
213
|
+
**For scheduled/automated execution:**
|
|
214
|
+
- Consider setting up cron jobs (Linux/Mac) or Task Scheduler (Windows)
|
|
215
|
+
- Ensure OAuth tokens are refreshed as needed
|
|
216
|
+
- Store reports in a centralized location for team access
|
|
217
|
+
|
|
218
|
+
## Built With
|
|
219
|
+
|
|
220
|
+
* [Python 3](https://www.python.org/) - Programming language
|
|
221
|
+
* [requests](https://requests.readthedocs.io/) - HTTP library
|
|
222
|
+
* [requests-oauthlib](https://requests-oauthlib.readthedocs.io/) - OAuth 1.0a support
|
|
223
|
+
* [python-dotenv](https://pypi.org/project/python-dotenv/) - Environment variable management
|
|
224
|
+
* [openpyxl](https://openpyxl.readthedocs.io/) - Excel file generation
|
|
225
|
+
* [keyring](https://pypi.org/project/keyring/) - Secure credential storage
|
|
226
|
+
* [MotorsportsReg API](https://www.motorsportreg.com/) - Event registration data source
|
|
227
|
+
|
|
228
|
+
## Contributing
|
|
229
|
+
|
|
230
|
+
_In Progress - Contribution guidelines to be developed_
|
|
231
|
+
|
|
232
|
+
## Versioning
|
|
233
|
+
|
|
234
|
+
This project uses [Semantic Versioning (SemVer)](https://semver.org/):
|
|
235
|
+
- **MAJOR** version for incompatible API changes
|
|
236
|
+
- **MINOR** version for new functionality in a backward compatible manner
|
|
237
|
+
- **PATCH** version for backward compatible bug fixes
|
|
238
|
+
|
|
239
|
+
**Current Version:** 1.0.0
|
|
240
|
+
|
|
241
|
+
## Authors
|
|
242
|
+
|
|
243
|
+
* **Kevin Homan** - *Initial work and project lead* - WDCR Time Trials Chief Competition Director
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
248
|
+
|
|
249
|
+
## Acknowledgments
|
|
250
|
+
|
|
251
|
+
* SCCA Washington DC Region for supporting the Time Trials program
|
|
252
|
+
* MotorsportsReg.com for providing API access
|
|
253
|
+
* WDCR HPDE program for combined event management
|
|
254
|
+
|
|
255
|
+
## Security Notes
|
|
256
|
+
|
|
257
|
+
**Important:**
|
|
258
|
+
- Never commit `.env` or `tokens/` directory to version control
|
|
259
|
+
- OAuth consumer secrets and access tokens must be kept confidential
|
|
260
|
+
- The `.gitignore` file is configured to exclude these sensitive files automatically
|
|
261
|
+
- Use `hpde-analytics-cli --configure` to store credentials securely in your system keyring
|
|
262
|
+
|
|
263
|
+
## Support
|
|
264
|
+
|
|
265
|
+
For issues or questions related to this tool, contact the WDCR Time Trials administration.
|
|
266
|
+
|
|
267
|
+
For MotorsportsReg API issues, refer to the [MotorsportsReg API documentation](https://www.motorsportreg.com/).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""API client module."""
|