Automatically email admin report CSVs on a recurring cadence

Hello,

I was hoping there might be a way to automate emailing the downloadable reports available on the Discourse admin panel to a defined email list on a recurring basis (like weekly or monthly CSV reports of Trending Topics, for instance).

In the meantime, I built my own Python script to get the data from the Discourse API and create a CSV, but if there’s already a pre-built solution I could use instead, I’d prefer it.

Thanks very much,
Paige

Unless you want to write a plugin, that’s what to do.

2 Likes

Discourse automation has this option you may find handy, can you try it out and let us know what you think?

2 Likes

Thanks for pointing this out, Sam - I had no idea it existed even after the amount of time I spent perusing various Discourse threads in my search for it.

Follow up question though: after looking through the existing SQL Data Explorer queries in the GitHub repo and making a few attempts at writing my own, is there somewhere where I can pull the query that generates the “Trending Search Terms” report available in the Discourse admin dashboard for the past month (term, search count, CTR)?

I’ve used the admin/reports/trending_search.json API to get the info manually, but I’d like to use a Discord cron job here if possible.

1 Like

I figured out the query to run in Data Explorer, it is:

SELECT term, count(*) searches, 
 sum(case when search_result_id is not null then 1 else 0 end) clicks,
 round(sum(case when search_result_id is not null then 1 else 0 end) * 100.0 / count(*), 1) as ctr
from search_logs
where created_at > current_timestamp - interval '30' day
group by term
order by count(*) desc

So my final, final question is: is there a way in the Automation, to have this query run and turn the results into a CSV attached to the email for the recipients instead of the results posted in the body of the email?

2 Likes

Not at the moment but it is a very good feature request, and should not be too hard to change

Can you post a dedicated topic for this ?

1 Like

Happy to. New feature request here - thanks very much!

1 Like

What does PM stand for?

PM is user for personal message
The second line also says “to your messages”

Yes but it hasn’t come to my messages therefore, I thought I may be missing something here.

Could I get this sent to my outlook instead?

As long as your outlook uses the same email address as your Discourse account, it should land there.

3 Likes