Question regarding add seed to bracket #120
-
Description: I tried to implement that to select and add a participant (one per time) as seed. I go through the library (refer to Coding References section), and found out that I need to add exact size of seed array with the While I think that I can implement the add single seed logic by resetting the database and re-create the bracket as below: var bracket;
function addSeed(name) {
var seedings = bracket.participant.map(x => x.name);
seedings.push(name);
createBracket(bracket.stage[0], seedings);
}
function createBracket(stage, seedings) {
window.inMemoryDatabase.reset();
await window.bracketsManager.create({
seeding: [],
... // Other configs
});
} For the above code, is it possible to be simplified, or any downside / bad practice if keep on reset and re-create the bracket? Coding References:
protected async updateSeeding(stageId: number, seeding: Seeding | null): Promise<void> {
...
if (seeding && seeding.length !== stage.settings.size)
throw Error('The size of the seeding is incorrect.');
...
} Question:
Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
But you can update the seeding a better way: see docs. You can use this method it with: And actually, I think you found a bug! 🎉 You can see the logic at creation time here: brackets-manager.js/src/create.ts Lines 456 to 487 in d987704 At creation time, you are not forced to give a full sized seeding: you can give an incomplete seeding array and specify the So, the bug I was mentionning is that I forgot to have the same behavior as create in update. These lines prevent you from giving an incomplete seeding indeed. Note: Currently, when your seeding is incomplete, it creates BYEs because in the library, I assume every time a bracket is created, the registrations are finished and it is ready to be started. There is not any kind of "registration time". See #59 So, until this bug is corrected (I'm quite busy these times), you can complete your seeding with brackets-manager.js/src/helpers.ts Lines 258 to 267 in d987704 Used like this: const completeSeeding = setArraySize(seeding, size, null); |
Beta Was this translation helpful? Give feedback.
But you can update the seeding a better way: see docs.
You can use this method it with:
window.bracketsManager.update.seeding()
And actually, I think you found a bug! 🎉
You can see the logic at creation time here:
brackets-manager.js/src/create.ts
Lines 456 to 487 in d987704