Data Explorer Plugin


(Jeremy M (Jerdog)) #108

What about a query to count how many times content has been shared? So:

  • Total Count of content shares by month
  • Highest shared content by month
  • User sharing the most content by month

(Rob Meade) #109


Ok, it’s fairly minor and doesn’t prevent functionality, it’s just a little erk-some…

On browseing to the Data Explorer;

“There are no queries. Why not create one?”

Yet the drop-down menu, in our case, currently yields three;

Perhaps this could be updated to say something like;
“No query selected. Would you like to create one?”

I don’t think there is value in returning the number of queries that have been created. Suggestion only…

(Rob Meade) #110

Feature Request

The dropdown menu of existing queries orders them in the order in which they were created, it would be nice if they could be ordered alphabetically, either instead, or as well as (configurable?);


(Jeremy M (Jerdog)) #111

Does this plugin present any new API endpoints, i.e. if we wanted to access the data from the query via the API?

(Jay Pfaffman) #112

Probably so. See

(Simon Cossar) #113

Yes, to get the data from a query you need to know the query’s ID. You can see the ID in the browser’s address bar when you run a query. To make an API request for the data you can do a query like this with CURL, with $api_key and $api_username set to the API credentials from your site and $query_id set to the query’s id.

curl -X POST -d "api_key=$api_key&api_username=$username"$query_id/run

It looks like it’s also possible to create queries through the API. I haven’t tried that yet though.

(Markus) #114

Hi friends,
is it possible to list all attachments via Data Explorer plugin and show some additional infos like:

  • File Size (MB)
  • linked posts
  • download / click counter
  • filetype
  • user who uploaded the file

This would be a great snippet for daily usage.

Thanks in advance!

(Gökhan Gurbetoğlu) #115

Is it possible to add an option to enable this for moderators? Any of these options:

  1. Allow moderators to create new queries and use them.
  2. Allow moderators to use only the queries created by the admins.

Especially an option to enable second one would be very useful. I want to let my moderators to run queries from time to time since I am mostly responsible for technical aspects of the forum but our moderators are the ones who know what is going on around the forum more than the admins.


At the moment, no, but we are working on surfacing approved queries (built by admins) onto the moderation dashboard to give mods the ability to run them. I don’t have a hard ETA on that though sorry.

(Brendan Schlagel) #117

Love this plugin so far! One thing that’s confused me is the implicit limits I see mentioned a couple places. Agree w/ the following that this could be made more clear.

Is there any way to override this limit of only showing 250 query results in the UI?

I tried adding a limit parameter but that doesn’t seem to affect the UI display so seems that’s only relevant for API calls. (Though that’s also good to know!)

(Kane York) #118

You can use the Download CSV button to get more results.

The intention of the rule that “the limit must be finite” is that you should acknowledge, by writing down a number, that the query might actually return that many results and you are prepared to handle it.

The JS app is not prepared to handle it, according to the testing I did when I determined the default limit of 250 :slight_smile:

But yeah I think that adding a small message when the limit is returned would be nice.

(Brendan Schlagel) #119

Cool that all makes sense! Just had me banging my head against the wall for a few minutes thinking my query was broken before I realized the implicit limit :smiley:

I think a message at the bottom like “Displaying max. 250 out of [x] total results” would help clarify. Not sure if it’d be easy to show total count of results like that while limiting # displayed. Ultimately I want to pull some data externally with an API call but the UI version is super nice + easier for writing and testing out queries.

(Gerhard Schlager) #120

Done. Sort queries alphabetically · discourse/discourse-data-explorer@4de3b1d · GitHub
Nice side effect: It also fixes random build errors. :slight_smile:

(Rob Meade) #121

Fab! Many thanks for this :slight_smile:

(Jeremy M (Jerdog)) #122

So this works - and is great! Thanks.

Continuing on this line of thinking, is it possible to pass along the params for the query in this? What about also passing in the api_key and api_username so that it is one link and not curl

(Simon Cossar) #123

Yes, it can be done. In a curl request you can pass the parameters as Form Data. Something like this will work:

curl -X POST -F "api_key=$api_key" -F "api_username=simon" -F 'params={"months_ago":"1"}'  http://localhost:3000/admin/plugins/explorer/queries/33/run

Get Post Id's of posts that a user liked
(Jeremy M (Jerdog)) #124

perfect… what about as part of the link itself and not use curl? Similar to:


How to collect user emails when they sign up
Send email to new users 24 hours after joining
(Simon Cossar) #125

I don’t think that can work. It has to be a POST request. If you’re running the query from another application, the easiest thing to do would be to make the request from your application’s server. That way, you should be able to avoid using curl.

(Pad Pors) #126

isn’t it better if this plugin be available for moderators as well?

currently only admins have access to the plugin, and mods get this error when clicking on the plugin: “The data explorer is only available to admins.”

moderators also need to be able to analysis some user behaviors, and direct access to the plugin helps.


This would give them complete read only access to your database. Not recommended in all cases I do not think

For example all they need to do is do

select * from api_keys

With that then they have access to the system & any admin generated API Keys allowing them to perform admin functions.