Skip to content

refactor(soccer-app): extract team query logic into reusable utility - #25

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

refactor(soccer-app): extract team query logic into reusable utility#25
ayushtr-aws wants to merge 1 commit into
mainfrom
bgagent/01KZP23QXZP7SGBY0ZRGZF4EKY/shared-orchestration-context-the-parent-epic-sever

Conversation

@ayushtr-aws

Copy link
Copy Markdown
Owner

Summary

Extracts the team search and sorting logic from soccer-app/src/App.tsx into a new reusable utility module soccer-app/src/utils/teamQuery.ts (TG-4).

The new module exposes:

  • SortKey type — "points" | "goals" | "name" | "league" (moved from App.tsx)
  • matchesSearch(team, searchQuery) — case-insensitive match against team name, league and country
  • compareTeams(a, b, sortKey) — the sort comparator (points/goals descending, name/league ascending)
  • queryTeams(teams, searchQuery, sortKey) — filters then sorts, returning a new array

App.tsx now imports queryTeams and SortKey and calls queryTeams(teams, searchQuery, sortKey) in place of the inline filter/sort chain. Behavior and UI are unchanged — same filtering fields, same sort keys and directions.

Decisions

  • Kept the exact same matching fields (name, league, country) and sort ordering to preserve current behavior.
  • Exported the SortKey type from the utility module so it remains the single source of truth shared by App.tsx; this matches the shared orchestration context's field/shape names (points, goals, name, league).
  • No changes to any UI, routes, or data shapes.

Build & test results

  • mise run build (tsc -b && vite build) → passed (built in ~161ms, 21 modules transformed).
  • mise run lint (oxlint) → passed, no findings.
  • Note: node_modules was not present initially and tsc was missing; ran npm install in soccer-app, after which build and lint succeeded.
  • The repo has no test suite; validation was via the build (type-check) and lint above.

Agent notes

  • What went well: The logic was self-contained and cleanly extractable. TypeScript's type-check via the build gave good confidence the refactor preserved behavior.
  • Difficult / gotchas: The initial mise run build failed with tsc: not found because soccer-app/node_modules was absent; running npm install inside soccer-app resolved it. Future tasks on this repo should ensure dependencies are installed in soccer-app/ (not the repo root).
  • Conventions discovered: The app lives under soccer-app/; mise tasks (build, lint, dev) proxy to npm scripts run in that dir. Linter is oxlint. Data/types live in src/data/teams.ts.
  • Suggestions for future tasks: Consider adding unit tests for teamQuery.ts (no test runner is configured yet). Sibling epic sub-issues can now import queryTeams/matchesSearch/compareTeams rather than duplicating logic.

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

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Task-Id: 01KZP23QXZP7SGBY0ZRGZF4EKY
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