Skip to content

Update: PGA Tour#397

Open
M0ntyP wants to merge 1 commit intotronbyt:mainfrom
M0ntyP:PGA-Tour-v2.12
Open

Update: PGA Tour#397
M0ntyP wants to merge 1 commit intotronbyt:mainfrom
M0ntyP:PGA-Tour-v2.12

Conversation

@M0ntyP
Copy link
Contributor

@M0ntyP M0ntyP commented Mar 6, 2026

Added different colour title bar for Playoff events, using "FedEx" purple
Added different colour title bar for Signature events, using an orange colour
Added opposite field event for the AP Inv...might be too late!
Added more entries for Tournament renaming map

@M0ntyP M0ntyP requested a review from tavdog as a code owner March 6, 2026 22:51
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the PGA Tour application by introducing visual distinctions for different event types and improving data accuracy. It provides clearer identification of Playoff and Signature events through unique title bar colors and refines tournament data by updating mappings and adding an opposite field event check. These changes aim to improve the user experience and data integrity within the application.

Highlights

  • Event Title Bar Colors: Implemented distinct color title bars for Playoff events, utilizing a 'FedEx' purple, and for Signature events, using an orange hue.
  • Tournament Mapping Updates: Expanded the tournament renaming map with additional entries and corrected existing tournament names for improved accuracy.
  • Opposite Field Event Logic: Added logic to identify the opposite field event for the Arnold Palmer Invitational.
Changelog
  • apps/pgatour/pga_tour.star
    • Updated the internal version history to v2.12, documenting the new features.
    • Expanded the TOURNAMENT_MAPPING dictionary with new tournament IDs and their abbreviated names, and corrected existing entries.
    • Extended the MAJOR_MAPPING dictionary to include specific color codes for FedEx Playoff events (purple) and Signature events (orange).
    • Modified the OppositeFieldCheck function to correctly identify the opposite field event for the Arnold Palmer Invitational.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the PGA Tour app by adding custom title bar colors for Playoff and Signature events, expanding the tournament renaming map, and adding logic for an opposite field event. My review includes suggestions to improve code maintainability by refactoring large data structures into a separate file and simplifying conditional logic. I've also pointed out a minor formatting issue.

Comment on lines 179 to 196
MAJOR_MAPPING = """
{
"401811937": "#003360",
"401811937": "#003360",
"401811941": "#006747",
"401811947": "#00205B",
"401811952": "#003865",
"401811957": "#1A1C3C"
"401811957": "#1A1C3C",
"401811962": "#4d148c",
"401811963": "#4d148c",
"401811964": "#4d148c",
"401811935": "#965115",
"401811942": "#965115",
"401811944": "#965115",
"401811945": "#965115",
"401811950": "#965115",
"401811953": "#965115"
}
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These large mapping dictionaries (TOURNAMENT_MAPPING, MAJOR_MAPPING, and also PLAYER_MAPPING) are defined as multi-line strings and then parsed from JSON. To improve readability and maintainability, consider moving them into a separate data.star file as native Starlark dictionaries and loading them directly. This would also eliminate the need for json.decode and align with repository best practices for large data structures.

For example, you could create apps/pgatour/data.star:

# apps/pgatour/data.star

TOURNAMENT_MAPPING = {
    "401811929": "The AmEx",
    # ... other entries
}

MAJOR_MAPPING = {
    "401811937": "#003360",
    # ... other entries
}

And then in pga_tour.star:

# apps/pgatour/pga_tour.star

load("data.star", "TOURNAMENT_MAPPING", "MAJOR_MAPPING")

# ... later in main()
# TournMapping = json.decode(TOURNAMENT_MAPPING) # No longer needed
# MajorMapping = json.decode(MAJOR_MAPPING) # No longer needed
TournMapping = TOURNAMENT_MAPPING
MajorMapping = MAJOR_MAPPING
References
  1. To improve readability and maintainability, move large data structures into a separate file and load them into the main application logic.

Comment on lines +636 to +637
elif ID == "401811935": # AP Inv -> Puerto Rico
i = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This if/elif chain is growing. To improve maintainability and readability, consider refactoring the OppositeFieldCheck function to use a dictionary for checking tournament IDs. This makes it easier to add or remove tournaments in the future.

Example refactoring:

def OppositeFieldCheck(ID):
    # check the ID of the event, and if its a tournament with an opposite field go to the second event in the API
    opposite_field_tournaments = {
        "401811945": True,  # Truist -> Myrtle Beach
        "401811957": True,  # The Open -> Barracuda
        "401811955": True,  # Scottish Open -> ISCO Champ
        "401811935": True,  # AP Inv -> Puerto Rico
    }
    return 1 if ID in opposite_field_tournaments else 0

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