{"id":48695098,"url":"https://github.com/saegey/fit-analysis","last_synced_at":"2026-04-11T07:13:15.597Z","repository":{"id":310392518,"uuid":"1038904786","full_name":"saegey/fit-analysis","owner":"saegey","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-17T19:04:56.000Z","size":15054,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-17T21:08:52.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saegey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-16T03:52:06.000Z","updated_at":"2025-08-17T19:04:59.000Z","dependencies_parsed_at":"2025-08-17T21:09:22.948Z","dependency_job_id":"e20a78f4-cef3-46f1-8cc3-d61984f2e800","html_url":"https://github.com/saegey/fit-analysis","commit_stats":null,"previous_names":["saegey/fit-analysis"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/saegey/fit-analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saegey%2Ffit-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saegey%2Ffit-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saegey%2Ffit-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saegey%2Ffit-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saegey","download_url":"https://codeload.github.com/saegey/fit-analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saegey%2Ffit-analysis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31671985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-11T07:13:15.006Z","updated_at":"2026-04-11T07:13:15.586Z","avatar_url":"https://github.com/saegey.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FIT File CLI (processFitFile)\n\nSmall CLI to process a `.fit` activity file and print a compact JSON summary.\n\n## Purpose\n\nThis binary was extracted from an AWS Lambda function. It decodes a FIT file, extracts activity records, runs the existing analysis logic, and prints a JSON object with only the fields you care about.\n\nThe CLI prints the following JSON fields:\n- `HeartAnalysis` (map / zone buckets)\n- `ElevationGain` (float)\n- `StoppedTime` (seconds)\n- `ElapsedTime` (seconds)\n- `NormalizedPower` (float)\n- `PowerAnalysis` (map / zone buckets)\nThe CLI may also include these additional fields when available:\n- `SimplifiedCoordinates` (array of [lon, lat, elevation] points)\n- `SimplifiedDistances` (array of distances aligned with simplified coordinates)\n- `SimplifiedElevations` (array of elevations aligned with simplified coordinates)\n\n## Prerequisites\n\n- Go 1.20+ (module-aware). Ensure `go` is on your PATH.\n- Run commands from the `src` directory (this repository's CLI package lives here).\n\n## Build\n\nTo build a local binary:\n\n```sh\ncd /path/to/.../processFitFile/src\ngo build -o processFitFile\n```\n\n## Run (development)\n\nYou can run without building:\n\n```sh\n# run against the included fixture\ngo run . --fit fixtures/Morning_Ride-8.fit\n\n# or with a built binary\n./processFitFile --fit fixtures/Morning_Ride-8.fit\n```\n\n## Testing\n\nRun all tests across the module (root and subpackages):\n\n```sh\ngo test ./...\n```\n\nVerbose output:\n\n```sh\ngo test -v ./...\n```\n\nRun a single test (by name pattern):\n\n```sh\ngo test -run TestName ./...\n```\n\nRun tests in a specific package (from repo root):\n\n```sh\ngo test -v .            # root package\ngo test -v ./fitHelper  # example subpackage\n```\n\nWith race detector:\n\n```sh\ngo test -race ./...\n```\n\nCoverage summary and HTML report:\n\n```sh\ngo test -coverprofile=coverage.out ./...\ngo tool cover -func=coverage.out\ngo tool cover -html=coverage.out\n```\n\nNotes:\n- Ensure Go is installed and your working directory is the repository root.\n- Some tests may read from `fixtures/` or `testdata/`; paths are relative to the package under test.\n\n## Example output\n\nThe program prints a single JSON object to stdout. Example (trimmed):\n\n```json\n{\n  \"HeartAnalysis\": { \"1\": 255, \"10\": 255, ... },\n  \"ElevationGain\": 0,\n  \"StoppedTime\": 15899,\n  \"ElapsedTime\": 35276,\n  \"NormalizedPower\": 183.89182,\n  \"PowerAnalysis\": { \"1\": 738, \"10\": 607, ... }\n}\n```\n\nIf the CLI includes the optional simplified timeseries, the output can also contain:\n\n```json\n\"SimplifiedCoordinates\": [[-122.4, 45.5, 123.4], [-122.401, 45.501, 124.3], ...],\n\"SimplifiedDistances\": [0, 12.3, 24.6, ...],\n\"SimplifiedElevations\": [123.4, 124.3, 125.0, ...]\n```\n\n## How it works (brief)\n\n- `main.go` is the CLI entry. It reads the `.fit` file, calls `ProcessActivityRecords`, and prints the requested JSON fields.\n- `process.go` contains the activity processing logic (power, cadence, simplification, etc.).\n- `fitHelper` decodes the FIT file and returns a `fit.ActivityFile`.\n- The program reuses existing `dynamo` types for the shape of analysis results.\n\n## Notes and next steps\n\n- Units: Elevation/Distance conversions follow the original code. If you want different units, we can change conversions in `process.go`.\n- Output file: I can add a `--out \u003cfile\u003e` flag to write the JSON to disk.\n- Tests: Add small unit tests for `ProcessActivityRecords` to guard behavior on small fixture files.\n\n## JSON Schema (validation)\n\nYou can validate the CLI output against the included JSON Schema. A schema is available at `src/output.schema.json` and matches the fields printed by the CLI (including the optional simplified arrays).\n\nExample validation with `ajv` (recommended):\n\n```sh\n# install ajv-cli if you don't have it\nnpm install -g ajv-cli\n\n# validate output.json against schema\najv validate -s output.schema.json -d output.json --strict=false\n```\n\nThe schema is also embedded below for quick reference.\n\n```json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"type\": \"object\",\n  \"additionalProperties\": false,\n  \"properties\": {\n    \"HeartAnalysis\": { \"type\": \"object\", \"additionalProperties\": { \"type\": \"integer\" } },\n    \"PowerAnalysis\": { \"type\": \"object\", \"additionalProperties\": { \"type\": \"integer\" } },\n    \"ElevationGain\": { \"type\": \"number\" },\n    \"StoppedTime\": { \"type\": \"integer\" },\n    \"ElapsedTime\": { \"type\": \"integer\" },\n    \"NormalizedPower\": { \"type\": \"number\" },\n    \"SimplifiedCoordinates\": {\n      \"type\": \"array\",\n      \"items\": { \"type\": \"array\", \"minItems\": 3, \"maxItems\": 3, \"items\": { \"type\": \"number\" } }\n    },\n    \"SimplifiedDistances\": { \"type\": \"array\", \"items\": { \"type\": \"number\" } },\n    \"SimplifiedElevations\": { \"type\": \"array\", \"items\": { \"type\": \"number\" } }\n  },\n  \"required\": [\"HeartAnalysis\",\"PowerAnalysis\",\"ElevationGain\",\"StoppedTime\",\"ElapsedTime\",\"NormalizedPower\"]\n}\n```\n\nIf you want any changes to the JSON shape or extra CLI flags, tell me which fields or flags and I will add them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaegey%2Ffit-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaegey%2Ffit-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaegey%2Ffit-analysis/lists"}