Drarig29 / brackets-manager.js

A simple library to manage tournament brackets (round-robin, single elimination, double elimination).
https://drarig29.github.io/brackets-docs
MIT License
245 stars 38 forks source link

Supporting metadata for matches #165

Open mikhail opened 1 year ago

mikhail commented 1 year ago

I'm trying to use the library to manage concurrent matches being executed in parallel. Imagine multiple tables for ping pong, or multiple baseball fields, parallel curling sheets, etc etc.

I'm envisioning metadata for Match objects that specify some parameter such as location_id. Is this the right approach? Would you accept a PR for this?

Understandable if the right solution here is to manage location independently of this library. Let me know!

Drarig29 commented 1 year ago

Understandable if the right solution here is to manage location independently of this library.

Yes, you're right. You should be handling this independently from the library :+1: When creating a stage, the library will create all the matches for you, by using the storage implementation you provided.

So if you implemented your own storage, you could add location_id on-the-fly. And the library won't know about it. For future match updates, the library will only do partial mutations of the matches, so your metadata will remain intact.

If you didn't implement a storage (or don't want to), you can use the in-memory storage implementation, add your metadata, then persist everything at once in your database. Or you should be able to create a new storage class which extends from JsonDatabase.

Manage concurrent matches being executed in parallel.

With this metadata, an approach would be to: