Skip to content

feat(soccer-app): add shared team metrics utilities - #29

Open
ayushtr-aws wants to merge 1 commit into
mainfrom
bgagent/01KZPA8T6FNVA1NRZSVEYMVHJV/shared-orchestration-context-the-parent-epic-sever
Open

feat(soccer-app): add shared team metrics utilities#29
ayushtr-aws wants to merge 1 commit into
mainfrom
bgagent/01KZPA8T6FNVA1NRZSVEYMVHJV/shared-orchestration-context-the-parent-epic-sever

Conversation

@ayushtr-aws

Copy link
Copy Markdown
Owner

Summary

Introduces reusable, typed soccer team metric helpers in a new soccer-app/src/utils/teamMetrics.ts module (TG-10). No UI changes — this only adds utilities for future consumption.

Exported helpers:

  • goalDifference(stats) — goals scored minus goals conceded (signed).
  • winRate(stats) — wins as a fraction of matches played, in [0, 1], rounded to 4 decimals for deterministic output. Returns 0 when no matches have been played (safe zero-division handling).
  • performanceLabel(stats) — a concise PerformanceLabel ("Elite" | "Strong" | "Average" | "Struggling") derived from the win rate. Teams with zero matches get a neutral "Average" default.

All helpers accept the existing TeamStats type from src/data/teams.ts and are pure/deterministic.

Task

TG-10: Add shared team metrics utilities (sub-issue of epic "ABCA Jira stacked corrections acceptance round 2").

Build & test results

Ran from soccer-app (dependencies installed with npm ci first, as node_modules was absent):

  • mise run build (tsc -b && vite build) — PASS: 20 modules transformed, built successfully.
  • mise run lint (oxlint) — PASS: no warnings or errors (exit 0).

The repository has no test suite; validation was done via the TypeScript compiler (strict noUnusedLocals/noUnusedParameters) and the linter.

Decisions made

  • Placed the module at the exact path required (soccer-app/src/utils/teamMetrics.ts) and reused the existing TeamStats interface rather than defining a new shape, to stay consistent with the codebase.
  • Chose win-rate-based thresholds for performanceLabel (0.7 / 0.5 / 0.3) as a simple, deterministic mapping. Zero-match teams return "Average" and winRate returns 0 to handle division safely.
  • Rounded winRate to 4 decimal places to keep outputs deterministic.
  • Used import type to comply with the project's verbatimModuleSyntax setting.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

Agent notes

  • What went well: The task was concrete and self-contained. The existing TeamStats interface made typing straightforward.
  • What was difficult: soccer-app/node_modules was not installed despite the setup step reporting mise install: OKtsc/vite/oxlint binaries were missing, so npm ci had to be run inside soccer-app before the build/lint tasks would work.
  • Repo conventions discovered: The app lives under soccer-app/; build is tsc -b && vite build, lint is oxlint (config in .oxlintrc.json). mise.toml at the root proxies build/lint/dev tasks into the soccer-app dir. TS config enables verbatimModuleSyntax, so type-only imports must use import type.
  • Suggestions for future tasks: Consider adding a test runner (e.g. Vitest) — there is currently no test suite, so utility correctness can only be verified via the compiler/linter. Ensuring soccer-app deps are pre-installed in the environment would also speed up build/lint verification.

Task-Id: 01KZPA8T6FNVA1NRZSVEYMVHJV
Prompt-Version: 1c9c10e027a2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant