Skip to content

fix: add Configuration filter support for moon2024 logbook queries#73

Open
rbatsenko wants to merge 2 commits intolemeryfertitta:mainfrom
rbatsenko:fix/moon2024-configuration-filter
Open

fix: add Configuration filter support for moon2024 logbook queries#73
rbatsenko wants to merge 2 commits intolemeryfertitta:mainfrom
rbatsenko:fix/moon2024-configuration-filter

Conversation

@rbatsenko
Copy link
Copy Markdown

Summary

This PR fixes moon2024 logbook support by implementing the required Configuration filter that the Moonboard 2024 API needs to return data.

Problem

The README currently states that moon2024 API is broken and returns no data. However, through investigation, I discovered that moon2024 requires both setupId and Configuration filters to work, unlike older board versions which only need setupId.

Without the Configuration filter:

filter=setupId~eq~'21'  # Returns 0 sessions ❌

With the Configuration filter:

filter=setupId~eq~'21'~and~Configuration~eq~'3'  # Returns data! ✅

Changes

  1. Modified logbook_pages() - Added optional angle parameter to build Configuration filter for moon2024
  2. Modified raw_logbook_entries_for_page() - Added same angle-based filtering support
  3. Updated raw_logbook_entries() - Special handling for moon2024 to query each angle (25° and 40°) separately since they require different Configuration IDs
  4. Updated README.md - Documented moon2024 partial support and API limitations

Technical Details

Moon2024 board configuration:

  • Board ID: 21
  • Angle IDs: 25° → 2, 40° → 3
  • Required filter format: setupId~eq~'21'~and~Configuration~eq~'3'

The existing ANGLES_TO_IDS mapping already had this data but it was only used for Dashboard endpoints, not Logbook queries.

Testing

Tested with real user data (username: rbatsenko):

  • Before fix: 0 entries for moon2024
  • After fix: 18 entries retrieved for 40° angle

Known Limitations

The Moonboard API itself has data inconsistencies:

  • Dashboard shows 26 climbs for 40° but Logbook API only returns 18
  • Dashboard shows 10 climbs for 25° but Logbook API returns 0 sessions

This PR enables BoardLib to retrieve the maximum available data from the broken API, which is better than the current behavior of returning nothing.

Backwards Compatibility

✅ All changes are backwards compatible:

  • New angle parameters are optional with default None
  • Older board versions (moon2016, moon2017, moon2019, moon2020) continue to work as before
  • Only moon2024 uses the new angle-based querying logic

References

  • Moonboard API endpoint: POST /Logbook/GetLogbook
  • Related issue: The README mentions moon2024 API is broken - this PR partially fixes it

The Moonboard 2024 API requires both setupId and Configuration filters
to return logbook data. Without the Configuration filter, the API returns
0 sessions even though data exists.

Changes:
- Modified logbook_pages() to accept optional angle parameter and build
  Configuration filter for moon2024
- Modified raw_logbook_entries_for_page() similarly to support angle-based
  filtering
- Updated raw_logbook_entries() to iterate over all angles for moon2024,
  querying each angle (25° and 40°) separately
- Updated README to document moon2024 partial support and API limitations

Technical details:
- moon2024 uses setupId=21 with Configuration IDs: 25°→2, 40°→3
- Filter format: setupId~eq~'21'~and~Configuration~eq~'3'
- The API has known data inconsistencies; Dashboard may show more climbs
  than the Logbook API returns

This fix enables BoardLib to retrieve available moon2024 data instead of
returning 0 entries. Tested with user data showing 18 entries retrieved
for 40° angle where Dashboard showed 26 climbs (API limitation documented).
Copilot AI review requested due to automatic review settings October 15, 2025 09:08
Copy link
Copy Markdown

Copilot AI left a 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 fixes the broken moon2024 logbook support by implementing Configuration filter support that the Moonboard 2024 API requires. The key insight is that moon2024 requires both setupId and Configuration filters, unlike older board versions that only need setupId.

  • Added angle-based Configuration filtering for moon2024 logbook queries
  • Modified logbook functions to handle moon2024's requirement for separate angle-specific queries
  • Updated documentation to reflect partial moon2024 support and API limitations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/boardlib/api/moon.py Added Configuration filter support and angle-based querying for moon2024
README.md Updated documentation about moon2024 partial support and API limitations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@rbatsenko
Copy link
Copy Markdown
Author

rbatsenko commented Oct 15, 2025

@lemeryfertitta here's the small fix to allow fetching 2024 logbook entries 🙂 (API is terrible as you know so possibly not a complete data, but at least smth!)
Claude figured it out 😄

Address GitHub Copilot feedback:
- Add ValueError with helpful message when invalid angle is provided
- Add 0.5s delay between angle queries to prevent API throttling
- Import time module for rate limiting

This prevents KeyError crashes and reduces risk of API throttling
when querying multiple angles for moon2024.
@lemeryfertitta
Copy link
Copy Markdown
Owner

@rbatsenko sorry for the late review! I went to go test this one and it looks like there may a new issue with logging in to the Moon API now, so I was unable to test it. If you're still interested and want to push a fix that includes the login so this is testable, I'll be sure to review it more promptly this time.

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.

3 participants