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

manager.get.currentMatches returns only Locked and Completed #172

Closed
Tandashi opened this issue Jun 28, 2023 · 5 comments · Fixed by #173
Closed

manager.get.currentMatches returns only Locked and Completed #172

Tandashi opened this issue Jun 28, 2023 · 5 comments · Fixed by #173
Labels
bug Something isn't working

Comments

@Tandashi
Copy link

Tandashi commented Jun 28, 2023

Currently I am running into the problem that manager.get.currentMatches only returns Locked and Completed matches.
It doesn't return the matches of the next round as expected.

The round contains 3 Matches where Participants have BYE matches (so participant vs no-one) and 1 Participant vs Participant match. Do I need to update the BYE matches manually to mark as completed?
(I would assume no if I understand to method Doc correctly)

Returns the matches that can currently be played in parallel.


If that is not the case here is my quick issue analysis.
A Match that has a BYE it will always get the status Locked (we'll see later why).
However the manager.get.currentMatches function checks if a rounds is completed as follows:

if (roundMatches.every(match => match.status >= Status.Completed))
    continue;

return roundMatches;

https://github.com/Drarig29/brackets-manager.js/blob/master/src/get.ts#L172

Since the Locked Status has a value of 0 this will never cause the round to be completed, thus returning a list of
Locked and Completed Matches.

I would assume that the issue lies somewhere here:

if (hasBye(match)) // At least one BYE.
        return Status.Locked;

if (match.opponent1?.id === null && match.opponent2?.id === null) // Two TBD opponents.
    return Status.Locked;

if (match.opponent1?.id === null || match.opponent2?.id === null) // One TBD opponent.
    return Status.Waiting;

if (isMatchCompleted(match))
    return Status.Completed;

https://github.com/Drarig29/brackets-manager.js/blob/master/src/helpers.ts#L686C1-L687C30

The first if check will always cause a Match to get the Locked Status if it contains a BYE.
Thus isMatchCompleted, which also accounts for BYE's, will never be reach.
Simply returning the Completed Status instead of the Locked one in the first return could already solve the issue.

@Drarig29 Drarig29 added the bug Something isn't working label Jun 28, 2023
@Drarig29
Copy link
Owner

Hey @Tandashi! Sorry for the delay.

I'm working on it, and thank you for reporting the issue 😄

@Tandashi
Copy link
Author

All good. Thanks for the heads up :)

@Drarig29
Copy link
Owner

@Tandashi could you try with the PR I opened?

To test it, you can do the following:

  • Clone this repository
  • Run npm install
  • Run npm link
  • In your project, run npm link brackets-manager

@Tandashi
Copy link
Author

Will do in a bit :)

@Drarig29
Copy link
Owner

Fix released in v1.5.9 😉

Tandashi added a commit to kocxyz/XYZBot that referenced this issue Jun 30, 2023
Updated the `brackets-manager` to the latest version which fixed the bye
completion issue.

Reference: Drarig29/brackets-manager.js#172
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants