Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve only matching football competition by tag #27713

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SiAdcock
Copy link
Contributor

@SiAdcock SiAdcock commented Jan 10, 2025

What is the value of this and can you measure success?

The competition by tag search only compares the tag we are looking for with the end of the competition tag.

If a competition tag ends with the same string as another competition tag, this can lead to an incorrect competition being sent.

Examples of tags in the competitions list:

/football/womens-super-league
/football/championsleague
/football/euro-2024
/football/euro-2024
/football/world-cup-2022-qualifiers
/football/uefa-europa-league
/football/women-s-nations-league
/football/nations-league

(full list)

In the above example, if we passed the tag "nations-league" to this function, the function would find the competition "/football/women-s-nations-league" before "/football/nations-league"

What does this change?

Ensure we are matching everything after football/ in the tag name, rather than the end of the tag

Screenshots

Before After
before after

Checklist

@SiAdcock SiAdcock linked an issue Jan 10, 2025 that may be closed by this pull request
@@ -26,7 +26,7 @@ trait Competitions extends implicits.Football {
competitions.filter(_.url == path),
)

def competitionsWithTag(tag: String): Option[Competition] = competitions.find(_.url.endsWith(tag))
def competitionsWithTag(tag: String): Option[Competition] = competitions.find(_.url.endsWith(s"/$tag"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we'd prefer to hardcode the football prefix into this check. Happy to discuss.

Suggested change
def competitionsWithTag(tag: String): Option[Competition] = competitions.find(_.url.endsWith(s"/$tag"))
def competitionsWithTag(tag: String): Option[Competition] = competitions.find(_.url == s"football/$tag")

@marjisound
Copy link
Contributor

@SiAdcock is it by purpose that in league selector disappears?

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.

Nations league results page wrong content
3 participants