Script systemThe scripting system is now ready, i may make still some small changes, in any case it can be used already. With this you can break down those few remaining limits coming from using SQL.
I was talking few days back about the problem of calculating the minimum amount of merits generated by simply receiving merits and not spent yet. That has proven to be quite difficult to be calculated solely with SQL, since trying to do many operations at the same time increase the complexity and generate convoluted queries which are hard to understand

Now i can show you how this can be done in an easier and more understandable way with the new scripting system.
How it works?Its a mix of Javascript and SQL that get injected and executed.
How to use it:With the scripting system you can basically use everything Javascript has to offer, i also added a set of functions to facilitate the interaction with the data:
- PrintTableResult(query_result_data): Draw a tabulated version of the data coming from a SQL query.
- RunSQLSynch(sql_command): Execute the SQL command specified and return an object containing the data
- RunSQLAsynch(sql_command): Execute the SQL command in asynchronous mode, the output cannot be captured back and just show the result of the query on table
- GetDataField(query_result_data,row_index,coulmn_index) given a query result get the field specified by row and column index
- GetCoulmHeader(query_result_data,coulmn_index) given a query result get the header data name by column index
- Length(query_result_data): number of rows we got from a query result
- WriteLine(text): output anything you want to show as a result of your operations
- Clear(): clear the output, anything that was written or displayed
If you make some mistake in building up your script, you should get an error hinting where the problem is, however i recommend to look into the Console of your browser if you encounter some problem you cannot wrap your head around (you can open it with F12, Console tab).
In here you can find all the SQL/Script examples and info:
https://github.com/AlbertoIT/Merit-Explorer-SQL/blob/master/README.mdLink to the tool: https://albertoit.github.io/Merit-Explorer-SQL/Any feedback appreciated, if you need help feel free to ask here
Here is an example on how to solve the problem stated above with an explanation (this is also the default script which will be loaded automatically as you select the Script tab):
