Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: randomize comment list #4

Closed
wants to merge 1 commit into from

Conversation

audrasjb
Copy link

@audrasjb audrasjb commented Nov 26, 2017

Comments list should be displayed in random order 😊

@imath
Copy link
Contributor

imath commented Nov 26, 2017

Hi @audrasjb

I agree the default order for AntiConferences topics (Camp comments) should be randomized. Your JavaScript workaround is interesting, but as it applies to all order options, i'm afraid it can disturb some users when they chose to order by number of votes for instance.

I think the random order must be added to the available ones into anticonferences_get_order_options() (before "date_asc") so that it is used as the default one, then this new order should be handled in the second part of this function anticonferences_parse_comment_query().

What's tricky with the random order is to carry on having consistent results for paginated ones (which is the case for topics). I've read this post by @hlashbrooke which seems to do the trick for posts, i'm sure there is a way to do it for comments in our case (and preferably without using a session variable 😉).

@hlashbrooke
Copy link

Getting a ping from an unfamiliar repo only happens about once every few years for me, so thought I'd stop by to give some input 😄

The solution in that post is essentially a MySQL solution - the seed value for random ordering will work in any MySQL query, whether it's in WP or not. The session variable is necessary to make sure you keep the same seed value for all queries, so if you can find an alternative way of doing that, then I'd love to hear about it. Perhaps store the seed value as a transient with the user ID, then set the transient to expire after 1 hour? A little janky maybe, but it could work.

As far as I can tell from looking the WP core, however, there's no filter for the ORDER BY clause for comment queries, so you might have to do a later filter on the entire query if you want to modify that.

@imath
Copy link
Contributor

imath commented Nov 27, 2017 via email

@imath imath self-assigned this Nov 30, 2017
@imath imath added this to the 1.0.3 milestone Nov 30, 2017
@imath imath closed this in 7c8fa27 Dec 1, 2017
@audrasjb
Copy link
Author

audrasjb commented Dec 1, 2017

Great job @imath @hlashbrooke !
Sorry for not being able to go further, I was too busy in recent days…
Glad to see that my workaround has led to a real improvement :)

Cheers,
Jb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants