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

(AstonJ) #1


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).

Sort User List By User Activity
(Jeff Atwood) #2

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

(Uwe Keim) #3

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…")

(AstonJ) #4

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

(Jeff Atwood) #5

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

(AstonJ) #6

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.

(Jeff Atwood) #7

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

(Sam Saffron) #8

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

(giorgia) #11

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 discourse/users-list-show.hbs at master · discourse/discourse · GitHub
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 discourse/directory-toggle.js.es6 at master · discourse/discourse · GitHub - 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:

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!

(giorgia) #12

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

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?

(Sam Saffron) #13

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

(Erlend Sogge Heggen) #14

@oblakeerickson can you assist here?

(Blake Erickson) #15

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

(Blake Erickson) #16

Okay, here is my PR:

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


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



(Sam Saffron) #17

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

For homepage we use:

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

(Blake Erickson) #18

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.

(Blake Erickson) #19

Okay, done.

FEATURE: Add order logic to admin users controller by oblakeerickson · Pull Request #4721 · discourse/discourse · GitHub

(Blake Erickson) #20

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

FEATURE: Add order logic to admin users controller by oblakeerickson · Pull Request #4721 · discourse/discourse · GitHub

so that it is more like the /latest endpoint.

(giorgia) #21

@oblakeerickson 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?

(Blake Erickson) #22

Let’s wait for my pr to be merged.