Is it possible to randomly select one (or more) users who have been active in the last week? To help get our forum up and going, we’d like to offer some weekly “door” prizes.
There is not a feature built into Discourse to do this. Your best bet is to run a Data Explorer query for active users, then use a random number generator to select someone.
There’s also the Weekly or monthly “best new user” badge - it’s currently monthly.
Here are the steps to create the random number with Excel after you have exported the data.
- Insert column with title “RandomID” or whatever you like
- Insert Excel function “=RAND()”
- Make sure no blank rows
- Copy the formula down the column
- Select and copy the entire column with the random values
- Paste special the entire column as values (so the numbers don’t change when you save the file)
- Sort lowest to highest
- Lowest number wins
Unfortunately I can’t use the data explorer because we’re only on the basic plan, but it looks like I can get similar information by using the latest posts API.
Obviously you could use the
/u users page API endpoint:
and then get additional pages with repeated calls similar to:
Be aware the
/u page and
/directory_items content is cached.
Thanks - I also discovered that yesterday when I learned that discourse front end uses the API so I can look for xhr requests.