Is there an quick way to create a report about number of forum users?
-
We have had our nodebb forum up and running for over two years and I think we have over 400 members. I would love to create a report of how many people have joined our forum over the months. Is there a feature or plugin in nodebb to generate reports about users? If not, how would you recommend I go about doing this?
-
Actually those are just "queries". But probably the easiest way, if you want it just for yourself is to run this in the browser console:
var months = {}; $.get('/api/users?page=1', (data)=>{ let putUsers = function(users){ users.forEach((user)=>{ let month = (new Date(Number(user.joindate))).getMonth(); months[month] = months[month] ? months[month] + 1 : 1; })}; putUsers(data.users); for (let i=2; i<=data.pagination.pageCount; i++) { $.get('/api/users?page='+i, (dataApi) => {putUsers(dataApi.users)}); } }) setTimeout(1000, console.log(months))
-
@arasbm alternatively, using the new fetch API in latest browsers:
const baseRoute = '/api/users'; fetch(baseRoute) .then(res => res.json()) .then(data => { const pageCount = data.pagination.pageCount; return Promise.all( // incremental array of pageCount elements Array.from({ length: pageCount }, (x, i) => i + 1) // map to an array of promises to page results .map(page => // fetch page fetch(`${baseRoute}?page=${page}`) .then(res => res.json()) // get user joindates .then(data => data.users.map(user => ({ joindate: user.joindate, username: user.username, })) ) ) ); }) // flatten pages .then(pages => [].concat(...pages)) // now you have an array of usernames + joindates // maybe make a CSV? .then(users => { const csv = users .map(user => `${user.username}, ${new Date(user.joindate).toISOString()}`) .join('\n'); console.log(csv); });
Which would output a CSV where column A and B are the username and joindate (in ISO format) respectively, with each user on a new line.
BTW, that code works on this site, if you open the JS console and paste it in, then wait for the result, it eventually writes the full list to console.
You can then import it into Excel of it's a one time use thing, or set up a more complicated script.
-
What I see as beneficial is a core feature (or a plugin I supposed) that exposes the database (read-only -- either Redis or Mongodb) keys in such a way that an administrator could create his own search queries with desired results.
I envision a picker of the thing that can be searched, a way to filter the results and then a picker on what fields should be displayed.
Does something like this exist?