The Data Explorer plugin allows you to make SQL queries against your live database, allowing for up-to-the-minute stats reporting.
After installing the plugin, head to
/admin/plugins. Click on the “Settings” button, and turn on “data explorer enabled”, then return and reload the page.
There should now be a tab in the stacked nav called “Data Explorer”. Select it, then use the + and Import buttons to create or import queries.
For an example, let’s import one that I wrote. Download this file, then open the import dialog and drag the file onto the dialog.
most-common-likers.dcquery (1).json (442 Bytes)
Click Import to save it to the server. Select the query from the drop-down box, and try running it with the Run Query button. (Note: For the purposes of demonstration, I checked the “Include query plan” box.)
Looks like all of the Discourse developers like each other quite a bit.
When you click any of the “Edit” buttons on a query view, or start a new Explorer Query, you are presented with a screen like the one below:
The top two boxes are the name and description of the query. The name is what you’re selecting in the dropdown box, and the description should be used for things like explaining what to put in the query parameters or to describe what data is being queried.
The left pane is where you write the SQL query. Minor syntax highlighting and checking is provided.
The schema explorer is on the right side of the writing pane. Note the red column names with a warning symbol, such as
salt - these are “Sensitive” columns. Try to avoid querying them if possible, reconsider querying them if you are in a public location, and definitely do not post screenshots of queries checking those columns without thinking about what you’re doing first.
-- [params] -- null string_list :words -- null string_list :categories -- user_id :user_id -- int :limit = 150 WITH words AS ( SELECT unnest(string_to_array( :words, ',' )) word ), cats1 AS ( SELECT unnest(string_to_array( :categories, ',')) cat ), -- ... AND p.user_id = :user_id -- ... LIMIT :limit
If you’re on a hosted Discourse forum and the data explorer doesn’t show up at /admin/plugins, email us at firstname.lastname@example.org to ask us to add it for you.
For self-hosted discourse forums, follow the Install A Plugin guide using https://github.com/discourse/discourse-data-explorer.git .