-
Notifications
You must be signed in to change notification settings - Fork 0
Initial version #1
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR introduces an initial version of an activities statistics tracking system with two main programs: a simple stub implementation (p1.js) and a comprehensive statistics calculator (p2/).
Changes:
- Added package.json with scripts to run both programs
- Implemented a full-featured activity statistics system in p2/ with data loading, validation, aggregation, and formatting capabilities
- Created a stub implementation in p1.js with placeholder functions for basic activity queries
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Defines project metadata and npm scripts for running both programs |
| p2/services/stats-calculator.js | Implements statistical calculations for activity data including averages, personal bests, and rankings |
| p2/services/aggregator.js | Provides utility functions for grouping, filtering, and aggregating activity data |
| p2/reports/formatter.js | Contains formatting functions to display statistics in various text formats |
| p2/index.js | Main entry point that loads data, validates it, generates statistics, and outputs formatted reports |
| p2/data/loader.js | Handles loading and validation of activity and activity type data from JSON files |
| p2/data/activities.json | Sample activity data for testing the statistics system |
| p2/config/activity-types.json | Configuration defining activity types with metadata like calorie rates and display names |
| p1.js | Stub implementation with placeholder functions for basic activity queries |
| README.md | Updated with repository description and link to internal documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| export function generateStatistics(activities, activityTypes) { | ||
| const types = getUniqueValues(activities, 'type'); |
Copilot
AI
Jan 23, 2026
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 activityTypes parameter is accepted but never used in this function. It should either be removed or utilized if it's intended for future functionality.
| const types = getUniqueValues(activities, 'type'); | |
| const types = | |
| Array.isArray(activityTypes) && activityTypes.length > 0 | |
| ? activityTypes | |
| : getUniqueValues(activities, 'type'); |
| avgDistance: aggregate(personActivities, 'distance', 'avg'), | ||
| avgDuration: aggregate(personActivities, 'duration', 'avg'), | ||
| avgHeartRate: aggregate(personActivities, 'heartRate', 'avg'), | ||
| totalElevation: aggregate(personActivities, 'elevation', 'sum'), |
Copilot
AI
Jan 23, 2026
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 field name 'elevation' is inconsistent with the activity data structure which uses 'elevationGain' as seen in loader.js validation and activities.json. This will cause incorrect aggregation results.
| totalElevation: aggregate(personActivities, 'elevation', 'sum'), | |
| totalElevation: aggregate(personActivities, 'elevationGain', 'sum'), |
| { person: 'Eve', distance: 2.5, type: 'swim', week: 'W03' }, | ||
| ]; | ||
|
|
||
| function getTotalRunDistanceForPerson(personName) { |
Copilot
AI
Jan 23, 2026
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 personName parameter is unused in this placeholder implementation. Consider adding a comment indicating this is a stub that needs implementation.
| function getTotalRunDistanceForPerson(personName) { | |
| function getTotalRunDistanceForPerson(personName) { | |
| // TODO: Implement this function to use `personName` and calculate the total run distance from ACTIVITIES. | |
| // Currently this is a stub implementation that ignores `personName` and returns a placeholder value. |
| return 123; | ||
| } | ||
|
|
||
| function getTopRunnerForGivenWeek(week) { |
Copilot
AI
Jan 23, 2026
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 week parameter is unused in this placeholder implementation. Consider adding a comment indicating this is a stub that needs implementation.
| function getTopRunnerForGivenWeek(week) { | |
| function getTopRunnerForGivenWeek(week) { | |
| // TODO: Placeholder implementation; `week` is currently unused and should be | |
| // used to determine the top runner for the specified week. |
| }] | ||
| } | ||
| } | ||
|
|
Copilot
AI
Jan 23, 2026
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 startingWeek and endingWeek parameters are unused in this placeholder implementation. Consider adding a comment indicating this is a stub that needs implementation.
| // TODO: This is a stub implementation; use startingWeek and endingWeek to calculate the most improved runner. |
No description provided.