solved Order Groups by Member Count

alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
I'm using Lucid & trying to order my groups by their member count.

Since that field doesn't show up in Site Builder (not a good sign) I tried the following:

 {jrCore_list module="jrGroup" order_by="group_member_count numerical_desc" limit="16" template="widget_list_grid_4_with_details.tpl" tpl_dir="jrGroup"} 

Still no luck. Any thoughts?

Thanks!

updated by @tatiana-dokuchic: 01/04/17 12:09:16AM
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Try:
order_by="group_members_count numerical_desc"
- with an 's' for the word 'members', maybe that will fix it.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
Hi Strumelia! That would have been a subtle and welcome fix. Unfortunately, no luck. Many thanks for the thought!
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Are you talking about a list of groups showing on your site home page (in your skin Index.tpl), OR the list of groups on your /group page (controlled by your Groups module "index.tpl") ? Or both locations?


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
paul
@paul
8 years ago
4,326 posts
My immediate thought was 'order_by="group_members_count numerical_desc"' as well but on checking the Group code that variable isn't available on the Group datastore (its added by a listener after the search parameters have been run) so that order_by will not work.
I'll take a look at the module and see it anything can be done.
Thanks


--
Paul Asher - JR Developer and System Import Specialist
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
I'm using Site Builder to replace both of those default pages and will have group lists (in different formats) on both. When I use the Data Browser to look at Groups I can see there is a group_member_count but I just can't seem to access it.
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
Thanks, Paul! Good luck :)
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Paul, my site is set up to show groups ordered by member count, so feel free to check my code to see what was done there if you like.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
paul
@paul
8 years ago
4,326 posts
Strumelia:
Paul, my site is set up to show groups ordered by member count, so feel free to check my code to see what was done there if you like.

Is it - where abouts? I'll take a look.


--
Paul Asher - JR Developer and System Import Specialist
paul
@paul
8 years ago
4,326 posts
Strum - You're using it here - http://fotmd.com/group - but if you scroll down you'll see its not working.


--
Paul Asher - JR Developer and System Import Specialist
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Huh? It's listing the groups from top to bottom in order of the number of members the group has...from group with most members, to group with least members. How is that 'not working'?

Edit: I see what you mean- Originally it listed everything in right order, but I think perhaps it has not readjusted itself properly as members have joined or left the group over time maybe? Or if members have been removed from the site? (leaving thier user ID# behind?)
Now I've simply added to the puzzle! :(




--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015

updated by @strumelia: 09/30/16 04:45:33PM
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
Could it have always been ordering from oldest group and it was just a fluke that the oldest groups were always the ones with the most members? Just a thought :)
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Nope. It was purposely set to order via number of group members.

In checking, it seems to be showing the correct current number of members for each group. So it's not RE-ordering when one group surpasses another, like it should be.



--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015

updated by @strumelia: 09/30/16 05:24:08PM
michael
@michael
8 years ago
7,714 posts
This is the query that is required:
SELECT member_group_id,  COUNT(member_id) as member_count FROM `jr_jrgroup_member` GROUP BY member_group_id order by  member_count desc

Who is joined to a group is not stored with information about the group. Can't see a simple way to do this, only a programmatic way.
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
I know my 60 or so groups originally got ordered correctly by member count way back before I went live a years ago, not sure how exactly it was done then (I do remember asking for help with it though)? I do see that they are NOT currently listed by the order they were created, so the question I have is-
what criteria IS being used for the order in which they are listed right now?

If my site is no longer correctly sorting them by member count as it did when I went live, then is there maybe just a way for me to MANUALLY edit the order in which they are listed on my site's /group page ?


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
paul
@paul
8 years ago
4,326 posts
The underlining issue here is that originally, the Group module stored its member data on its datastore and the 'group_members_count' field was part of that process. You can order by any datastore field so ordering by member count worked.
In a later release, it was changed so that group members are stored on a seperate table. This was to make things more effecient for groups with large numbers of members. Unfortunately, at that point, the 'group_members_count' field disappeared from the group datastore.
I'm going to fix it so that ordering by group members is doable again in the next release of the module.
hth


--
Paul Asher - JR Developer and System Import Specialist
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
Thanks, Paul!
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Awesome!!!! Thank you SO MUCH Paul!

The Jamroom Team is just so amazing and responsive to customer needs.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
michael
@michael
8 years ago
7,714 posts
The new version of this module is in the marketplace now:
Version 1.5.8: - New: "group_member_count" key added to allow sorting of lists based on group membership count

Strumelia, could you change the templates that you have being over-ridden to use the non-s version of the variable.

Run the integrity check after getting the module updated to get the 'group_member_count' created. Then update
ACP -> SKINS -> (YOUR CURRENT SKIN) -> index.tpl -> MODIFY

order_by="group_member_count numerical_desc"

That should get you working correctly again.
alt=
Tatiana Dokuchic
@tatiana-dokuchic
8 years ago
83 posts
Excellent, Michael. Thank you very much.
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
michael:
Strumelia, could you change the templates that you have being over-ridden to use the non-s version of the variable.
Run the integrity check after getting the module updated to get the 'group_member_count' created. Then update
ACP -> SKINS -> (YOUR CURRENT SKIN) -> index.tpl -> MODIFY
order_by="group_member_count numerical_desc"
That should get you working correctly again.

Yes that worked great- all is working most excellently now again. THANK YOU!!! :)


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
michael
@michael
8 years ago
7,714 posts
Thanks for fixing that up. :)