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

S24 recim bracket v2 #1057

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open

S24 recim bracket v2 #1057

wants to merge 23 commits into from

Conversation

amos-cha
Copy link
Contributor

@amos-cha amos-cha commented Jul 1, 2024

Mirror UI component: gordon-cs/gordon-360-ui#2347

Rec-IM's old bracket component is no longer being updated and has quickly become an update bottleneck when we attempted to upgrade to react 18. This API PR is a has a UI mirror to handle the change to a new bracket component and its specifications.

The main key pieces required to update packages was

  1. Generating bye matches where no teams exist. My previous implementation would simply not create the matches at all and as I wanted to keep it that way, logic is now used when getting match bracket data to fill out the empty spots on the bracket.
  2. Next Match needs to be known, once again without modifying my old code, I was able to simply organize my list of matches and find the appropriate next match algorithmically.

@amos-cha amos-cha added Feature A new feature Broken Feature Issues tagged with this label require a more rapid fix than normal bugs. s24 Summer Practicum 2024 labels Jul 1, 2024
@amos-cha amos-cha self-assigned this Jul 1, 2024
@amos-cha amos-cha marked this pull request as draft July 1, 2024 20:34
@amos-cha
Copy link
Contributor Author

amos-cha commented Jul 2, 2024

TODO:
Next Match ID

@amos-cha amos-cha requested a review from EjPlatzer July 8, 2024 13:04
@amos-cha amos-cha marked this pull request as ready for review July 8, 2024 13:04
@amos-cha amos-cha requested review from jsenning and russtuck July 8, 2024 20:41
Copy link
Member

@russtuck russtuck left a comment

Choose a reason for hiding this comment

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

This is good work, and much of it is quite clear. But the heart of the code is complex and hard to decipher, which means maintenance in the future will be hard. Please make it clearer, so it can stay working for years to come. That might mean high-level comments explaining what it's doing, or refactoring into smaller methods with clear names and functions. The latter might be better, but either is fine.

using System.Collections.Generic;

namespace Gordon360.Models.ViewModels.RecIM;
//UI SHAPE
Copy link
Member

Choose a reason for hiding this comment

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

This example doesn't match the definition of MatchBracketExtendedViewModel below. Why is that? It needs an explanation (unless it just needs an update to match the class).

// "nextMatchId": null, // Id for the nextMatch in the bracket, if it's final match it must be null OR undefined
// "tournamentRoundText": "4", // Text for Round Header
// "startTime": "2021-05-30",
// "state": "DONE", // 'NO_SHOW' | 'WALK_OVER' | 'NO_PARTY' | 'DONE' | 'SCORE_DONE' Only needed to decide walkovers and if teamNames are TBD (to be decided)
Copy link
Member

Choose a reason for hiding this comment

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

Are these values explained somewhere?

I don't know what WALK_OVER and NO_PARTY mean, and a search of the repo doesn't show them elsewhere. And I'm wondering if DONE implies there is no score (since it's different from SCORE_DONE).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are definitions that are explained in the UI package docs. I don't think it is necessary to explain in the API

public string? state { get; set; }
public DateTime startTime { get; set;}
public IEnumerable<TeamBracketExportViewModel> participants { get; set; }
public int seedIndex { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

It might be helpful to add a comment that seedIndex is a numbering of teams from 0 to n-1, essentially a tournament seeding. NOT the seed for a randomized algorithm for assigning position in the tournament. (Assuming I've guessed correctly based on reading some of the other code.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not exactly, the seed index is the index of where that match exists in each round. its purely a calculation necessity

* 2) need 'next match ID
* 3) status needs to be translated to 'state' enum
*/
var match = context.Match
Copy link
Member

Choose a reason for hiding this comment

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

What can we assume about context.Match?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what this means, context.Match is how we access our Match models in the DB. The code itself should be relatively self explanatory of why I need to contain Match.

}
}

//final conversion to exact UI shape (more efficient than letting the UI handle the key/pair changes
Copy link
Member

Choose a reason for hiding this comment

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

This is a good comment: it explains the goal clearly enough that the code below it makes sense.

The code above could use some similar comment(s).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a comment. All the code above does, is as I described:
It fills out all the invisible bye matches and injects nextMatchID into each bracket object

public string? state { get; set; }
public DateTime startTime { get; set;}
public IEnumerable<TeamBracketExportViewModel> participants { get; set; }
public int seedIndex { get; set; }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not exactly, the seed index is the index of where that match exists in each round. its purely a calculation necessity

// "nextMatchId": null, // Id for the nextMatch in the bracket, if it's final match it must be null OR undefined
// "tournamentRoundText": "4", // Text for Round Header
// "startTime": "2021-05-30",
// "state": "DONE", // 'NO_SHOW' | 'WALK_OVER' | 'NO_PARTY' | 'DONE' | 'SCORE_DONE' Only needed to decide walkovers and if teamNames are TBD (to be decided)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are definitions that are explained in the UI package docs. I don't think it is necessary to explain in the API

Gordon360/Services/RecIM/SeriesService.cs Outdated Show resolved Hide resolved
* 2) need 'next match ID
* 3) status needs to be translated to 'state' enum
*/
var match = context.Match
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what this means, context.Match is how we access our Match models in the DB. The code itself should be relatively self explanatory of why I need to contain Match.

}
}

//final conversion to exact UI shape (more efficient than letting the UI handle the key/pair changes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a comment. All the code above does, is as I described:
It fills out all the invisible bye matches and injects nextMatchID into each bracket object

@amos-cha amos-cha requested a review from russtuck July 10, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Feature Issues tagged with this label require a more rapid fix than normal bugs. Feature A new feature s24 Summer Practicum 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants