Skip to content

feat: surface optional course fields on score rows#44

Merged
boorad merged 3 commits into
mainfrom
feat/score-course-fields
Jun 16, 2026
Merged

feat: surface optional course fields on score rows#44
boorad merged 3 commits into
mainfrom
feat/score-course-fields

Conversation

@boorad

@boorad boorad commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Passes through three optional course-identifier fields on score rows returned by the GHIN getScores endpoint. schemaScore previously stripped these, so consumers had no way to tell which course each score was played at.

Changes

  • schemaScore now surfaces course_id (string or number), course_name, and facility_name
  • All three are .nullable().optional() to stay backward-compatible with responses that omit them
  • Added score.test.ts covering present, numeric course_id, and absent cases
  • Added a patch changeset

Testing

  • bun run test:run — new schemaScore tests pass
  • ./scripts/code-quality.sh — biome, lint+tsc, and build all pass

Summary by CodeRabbit

  • New Features
    • Score results now include optional course details—course ID, course name, and facility name—so each score can be associated with the course it was played on.
  • Bug Fixes
    • Score row processing no longer drops course identifiers returned by the source, preserving them for consumers.
  • Tests
    • Added unit tests to verify course and facility field parsing (string, numeric, omitted, and null cases).

Pass through course_id, course_name, and facility_name from the GHIN
getScores response. These were previously stripped by schemaScore, so
consumers had no way to tell which course each score was played at.
All three are optional and nullable to stay backward-compatible with
responses that omit them. Adds tests covering present, numeric
course_id, and absent cases.
@boorad boorad self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: afcd13bb-4c1e-4f3e-8ac6-b25a17c2b587

📥 Commits

Reviewing files that changed from the base of the PR and between 3c3ca47 and e502634.

📒 Files selected for processing (2)
  • .claude/commands/fix-pr.md
  • src/client/ghin/models/scores/score.test.ts

📝 Walkthrough

Walkthrough

schemaScore gains three optional nullable fields — course_id (string or number), course_name, and facility_name — passing through course identifiers returned by the GHIN API. A new Vitest suite validates pass-through, numeric coercion, and field omission. A patch changeset documents the addition.

Changes

Optional Course Fields in schemaScore

Layer / File(s) Summary
schemaScore fields, tests, and changeset
src/client/ghin/models/scores/score.ts, src/client/ghin/models/scores/score.test.ts, .changeset/manual-player-course-fields.md
schemaScore adds course_id (string/number, nullable, optional), course_name (string, nullable, optional), and facility_name (string, nullable, optional). Tests cover value pass-through, numeric coercion for course_id, and omission resulting in undefined. Changeset records a patch release for @spicygolf/ghin.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hippity-hop, three fields appear,
course_id, course_name, now crystal clear!
facility_name joins the score's parade,
No more stripped fields — the rabbit's afraid
of lost courses! Tests hop through each case,
The changeset stamps a patch with grace. 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: surface optional course fields on score rows' accurately and clearly describes the main change: adding optional course identification fields to score rows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@8fe853c). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #44   +/-   ##
=======================================
  Coverage        ?   95.81%           
=======================================
  Files           ?       54           
  Lines           ?     2533           
  Branches        ?      426           
=======================================
  Hits            ?     2427           
  Misses          ?      106           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/client/ghin/models/scores/score.test.ts (1)

53-78: ⚡ Quick win

Add test coverage for null values.

The schema marks course_id, course_name, and facility_name as .nullable(), but the test suite doesn't verify that explicit null values parse correctly. Consider adding a test case:

it('accepts null for course fields', () => {
  const parsed = schemaScore.parse({
    ...baseScore,
    course_id: null,
    course_name: null,
    facility_name: null,
  })
  expect(parsed.course_id).toBeNull()
  expect(parsed.course_name).toBeNull()
  expect(parsed.facility_name).toBeNull()
})

This ensures the .nullable() behavior is validated and distinguishes null (explicitly absent) from undefined (field omitted).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/client/ghin/models/scores/score.test.ts` around lines 53 - 78, Add a new
test case to the schemaScore describe block that validates null values are
accepted for the course fields. The test should parse an object containing
baseScore with course_id, course_name, and facility_name explicitly set to null,
then assert that each parsed field is null (not undefined). This distinguishes
explicit null values from omitted fields and ensures the nullable schema
behavior is properly tested. Add this test case after the 'treats the course
fields as optional' test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/client/ghin/models/scores/score.test.ts`:
- Around line 53-78: Add a new test case to the schemaScore describe block that
validates null values are accepted for the course fields. The test should parse
an object containing baseScore with course_id, course_name, and facility_name
explicitly set to null, then assert that each parsed field is null (not
undefined). This distinguishes explicit null values from omitted fields and
ensures the nullable schema behavior is properly tested. Add this test case
after the 'treats the course fields as optional' test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3d9328e-5c7a-461a-bb4b-26033137da23

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe853c and 3c3ca47.

📒 Files selected for processing (3)
  • .changeset/manual-player-course-fields.md
  • src/client/ghin/models/scores/score.test.ts
  • src/client/ghin/models/scores/score.ts

boorad added 2 commits June 15, 2026 22:37
Address CodeRabbit nitpick on #44 — verify course_id, course_name, and
facility_name parse correctly when explicitly null, distinguishing null
(present) from undefined (omitted).
@boorad

boorad commented Jun 16, 2026

Copy link
Copy Markdown
Owner Author

Addressed CodeRabbit nitpick: added a test verifying course_id, course_name, and facility_name parse correctly when explicitly null (distinguishing null from undefined). Pushed in 508231a.

@boorad boorad merged commit b94cad0 into main Jun 16, 2026
7 checks passed
@boorad boorad deleted the feat/score-course-fields branch June 16, 2026 02:48
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