Turn Data Explorer query results into CSV to attach to Discourse automated emails

Follow up feature request spawned from this previous thread

With Discourse automation, I’m able to run a Data Explorer query on a recurring cadence to pull the values constituting the Trending Search Terms report that can be downloaded as a CSV from the Discourse Admin panel.

Running the query through Automation, however, puts the results into the body of the email instead of giving me the option to attach the results as a CSV or JSON file to the email, which is what I’d prefer so I can open the attachment upon receipt and sort and filter it with Excel.

Can you please make the option to attach the results of the Data Explorer query an option when scheduling a PM with Data Explorer results via Discourse Automation?

4 Likes

Hey Paige,

I ran this request by the engineer who worked on this automation feature. We think it could be useful to add a new field to the automation (something like “Attach report as CSV”) but are not sure of the priority as we have only got one customer request for it at the moment. We’re thinking about leaving this topic open to see if we get more requests before putting it on the roadmap or on pr-welcome.

2 Likes

Thanks for following up on this, I appreciate it.

I’ll use my homespun Python script in the meantime, and hope that this gets added to your automated features at some future date.

2 Likes

Good morning,

Follow up request to add on to the original: please include all search terms beyond the first 100 in the report.

I ask because I receive an automated email report from Discourse of the search terms over the past month to compare to my homemade script that I run to create a CSV of the same data, but while the script only gets the first 100 top terms, the automated email for the month of August had 300+ terms.

Looking at the JSON returned from the Discourse API endpoint, however, I see no boolean flag, query param, etc. that I can specify to get all the results.

Just to check, are you using a specific report that’s for the top 100? I think there’s a version here without a limit on if that would work better for you?

As far as I know, I’m not.

I’m hitting the Discourse trending search API endpoint https://my_company_discourse/admin/reports/trending_search.json?start_date=2023-08-01&end_date=2023-08-31 with my Python script and supplying the various start and end dates, but it only returns the first 100 results.