-
Notifications
You must be signed in to change notification settings - Fork 10
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
MySQL Compatible #2
Comments
Hi, hello! Thanks for opening an issue here! |
No worries! Thank you for the screenshots, they help me understand it a bit better. It does indeed look to be a bit more challenging than I at first thought, because you can have multiple databases, each with a different layout, and they all have to combine into one table. (adding to that the fact that users are stored by UUID, not playername) After having thought a bit, I think it can be done with a semi user-configurable setup with a JSON config file, so here is my idea. The following example is for 2 databases with 1 table each, the first one being in the format of your screenshot, the second one would be for when you just have the columns [
{
"database": "db1",
"table": "table1",
"key": "uuid",
"columns": ["value"],
"convert": ["uuid", "json"],
"renameColumns": { "uuid": "player" }
},
{
"database": "db2",
"table": "table2",
"key": "player",
"columns": ["exp", "money"]
}
] There would then be a couple of pre-defined mapping functions (each with the same signature) that convert an entire data row: (it might be better/easier to convert only a single item at a time instead of an entire row, but not sure)
The PHP script would need to combine multiple rows, tables and databases into a single data object.
For your screenshot, the above configuration should produce the following table. I hope this is about how that data should be displayed? I'm not sure what
Do you think this would be flexible enough to use for the other plugins you use? Edit: a large part of this is notes to myself, thought I'd include it for completeness |
Wow, after reading this, I'm am appalled! You went insane on planning this out! My previous example with The configuration certainly seems very flexible and could work with a variety of setups. I've also included another Databse setup, to provide further usage possibilities: |
Well, it has been some time (busy with exams, went on holiday, had other stuff to do, etc.) but I did something! The configuration format is even more powerful now (almost created an entire programming language 😄), although I think I missed some things still (like the table1 is like your first screenshot (what it looks like in mysql)
table2 is just plain
table3 is like your last screenshot
This would be a possible configuration file for it: [ // array of configuration items, each for one database-table combination
{
"database": "db1",
"table": "table1",
"convert": [ // array of conversion operations, performed in-order
["json", "value"], // json command takes a column argument; that column will be converted from json
["uuid", "uuid"], // uuid command also takes a column argument
["rename", "uuid", "player"] // rename command takes two column names
// ("uuid" column will be renamed to "player" here)
]
},
{
"database": "db1",
"table": "table2"
// convert array is optional
},
{
"database": "db1",
"table": "table3",
"convert": [
["key-value", "category", "count"], // key-value unpack takes two columns,
// the value of the first column is the key and will become a column,
// the value of the second column will be its value
["rename", "playerID", "player"] // rename "playerID" column to "player"
]
}
] In order to merge the different tables into one, every table needs to end up with a "player" column. Installation should be as easy as uploading the php files and pointing everything to each other. I added a configuration option to the JS part so you can manually set up the URLs like this: (this replaces the new WebStats({
connection: new Connection({
scores: "path/to/stats.php",
online: "http://ip:port/online.json"
})
// ... rest of config
}) Also, the I hope this is of use to you. If you have trouble with anything, I would be very glad to help! I will write more extensive documentation in the readme soon, as well as work on one or two more converter functions - please let me know if you have other ideas! |
Woah, thank you so much for all your unbelievable hard work! The format is extremely flexible, and all the effort you put into this is greatly appreciated! |
I realised last week that I could just as well have done it in Java, but somehow my brain immediately goes PHP when someone mentions mysql. So, I rewrote it in Java 😁 (and implemented the
I also wrote a small explanation for the conversions in the readme. |
Hey, would you ever consider making this MySQL compatible? I love the idea here, but I don't use the Scoreboard and store all my Data in MySQL.
The text was updated successfully, but these errors were encountered: