Make /admin/users/list sortable? (suggestion)

By:

Seen, Topics Viewed, Posts Read, and Read Time

I think this would be helpful in seeing who is potential mod material (and which mods are not as active as you would expect a moderator to be).

3 Likes

This is already possible on /users so I’m not quite sure why it would need to be duplicated in admin?

2 Likes

Maybe it is confusing to see it working on one list but not on another?

("…I am sure that it worked yesterday, but it seems it stopped working…")

3 Likes

Mainly to see which staff members are most/least active.

1 Like

You can do that in public through a group, see Discourse Meta

It’s missing the some important info though (I would also add number of replies).

A forums and mod teams grow I think having something like this would be handy. Or perhaps add some sort of ‘mod criteria’ system (so for example, if a mod has been absent for 14 consecutive days (or some other criteria is met or not met) they are automatically removed from the mod group.

The groups page is a more useful place to focus that effort, though.

2 Likes

Note, we are clearly not against this feature, its just a question of priorities and admin pages are usually last to win the priority race

Putting a pr welcome tag on this

8 Likes

Hi! I’m working on this issue, i was able to build some html of sortable users list in admin users list, i also recreate all the necessary steps to call the sortable function but for some reason it doesn’t re-render and so it doens’t sort.

Basically in https://github.com/discourse/discourse/blob/master/app/assets/javascripts/admin/templates/users-list-show.hbs
i change table titles to:

 {{admin-directory-toggle field="last_seen" order=order asc=asc}}
        {{admin-directory-toggle field="admin.user.topics_entered" order=order asc=asc}}
        {{admin-directory-toggle field="admin.user.posts_read_count" order=order asc=asc}}
        {{admin-directory-toggle field="admin.user.time_read" order=order asc=asc}}

Where admin-directory-toggle is a copy of https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/directory-toggle.js.es6 - but without 'directory.' + on line 11 and line 22, in order to get the correct translation.

Everything seems to work correctly, the order and the field are set as equal and then the bufferedRender is called.
But then the admin template, doesn’t actually reload, which instead the user one, does.
The incongruence is happening here:
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse-common/lib/buffered-render.js.es6#L14

I’m bit stack, do i have to do something in particular to make the render, re-render the html?

Or maybe my problem is the tbody of admin table and how is build?
(i notice that /users tbody is all emeberView, instead admin tbody is not. But it doesn’t look like is matching any ids… )

If anyone can point me to direction where to look at, it could keep on from there!

5 Likes

I was able to fix my above issue, now all the frontend part works smoothly: arrow is shown once clicked, page reload and do a call to get elements in the right order, params are added to the query.

Problem? There is no API for that (at least i didn’t find it)

/users table get sorted with a call to directory_items?order=... which works thanks to DirectoryItems model
https://github.com/discourse/discourse/blob/70782dcc0b0fe801f91e63b4f9975cb13e09c2b0/app/models/directory_item.rb

which make me assume i need something similar for admin user.
i’m not a backend developer so i wouldn’t be able to do this alone, is there any place where i could ask if anyone with enough rails skills would support me?

maybe @erlend_sh you know this?

Yeah this needs to be added…

/admin/users/list/new.json and family should accept a ?sort_column param and a &sort_direction (asc/desc) param

1 Like

@blake can you assist here?

1 Like

@designbygio just letting you know I’m working on the api changes for this :slight_smile:

5 Likes

Okay, here is my PR:

https://github.com/discourse/discourse/pull/4721

You can sort by these columns:

created_at, trust_level, last_emailed_at, last_seen_at, username, email, days_visited, posts_read_count, topics_entered, post_count, time_read

Example:

/admin/users/list/active.json?order=post_count (which defaults to desc)

and

/admin/users/list/active.json?order=post_count&ascending=true

11 Likes

We should ensure ascending / descending semantics are the same in our various parts of our API.

For homepage we use:

https://meta.discourse.org/latest?ascending=true&order=posts

I would recommend normalizing this, for the record I do like asc a bit better

4 Likes

I totally agree!

I did base it off: Discourse Meta :wink:

I’ll make the asc → to ascending change in my pr and maybe down the road we can update the above url too so that everything is the same.

3 Likes

Okay, done.

https://github.com/discourse/discourse/pull/4721/commits/e9d5c3265cffce7dc2c76e745b9ef9271fb85672

2 Likes

Added another pr for mapping order values to database column names:

https://github.com/discourse/discourse/pull/4721/commits/0e6cb752dab3f1fd204f93e192b5626db066dd50

so that it is more like the /latest endpoint.

3 Likes

@blake many thanks!

What’s the best proceedure now, should I wait your PR to be merged and then i do mine or rather I pull from your PR and do my PR, referring to yours?

Let’s wait for my pr to be merged.

3 Likes