thewca / statistics

12 stars 16 forks source link

[Feature Request] Autocomplete for database queries #110

Open simonkellly opened 4 months ago

simonkellly commented 4 months ago

It would be cool to have a code editor with autocomplete on the database query page, as I frequently find myself writing queries within the ruby mine console and copying them over.

This could be accomplished a number of ways, but the easiest appears to be a library called CodeMirror (which has a react wrapper https://uiwjs.github.io/react-codemirror/#/).

It might be an idea to do maybe a toggle to allow users to choose if they want to use the code editor or the previous textbox setup.

Schema definitions could be generated after each db import into a static json file from the java server using a sql query which looks something like this

SELECT CONCAT('"', TABLE_NAME, '": ', '[', GROUP_CONCAT(CONCAT('"', COLUMNS.COLUMN_NAME, '"'), ''), '],')
FROM   COLUMNS
WHERE TABLE_SCHEMA='wca_development'
GROUP BY TABLE_NAME

I made a quick example implementation (without the dynamic generation of the schema) on my fork https://github.com/simonkellly/statistics/tree/feature/code-editor which is based on the vite changes branch.

image image