The attached patch adds a views sort on the subscriber count. It relies on a yet uncommitted views patch #143888, This code properly checks for the patch, so it could be applied even before the views patch is committed.

Comments

dww’s picture

Project: OG Project » Organic Groups
Version: 5.x-1.x-dev » master
Component: Code » og.module

Moving to the right queue. OG Project is only about integrating OG and project.module (well, at this point, really project_issue.module).

moshe weitzman@drupal.org’s picture

good advertisement for your patch :)

i'll try to review that patch and push it along. i won't commit this until that one is in.

douggreen’s picture

StatusFileSize
new1.53 KB

@dww, sorry
@moshe, thanks!

Attached is a slightly updated patch that removes one line of code. The default join type is 'inner', so this line was not needed.

Christefano-oldaccount’s picture

This will be very useful. Thanks, Doug!

Bevan’s picture

Version: master » 5.x-4.3
StatusFileSize
new1.53 KB

Re-rolled patch for head

moshe weitzman’s picture

Status: Needs review » Needs work

looks to be missing the is_active check for a subscription

douggreen’s picture

Status: Needs work » Needs review
StatusFileSize
new1.55 KB

Thanks! I missed that og_uid had this field. I added ou.is_active > 0 to the SQL WHERE clause. The > 0 check will catch everything, and there's really no benefit to making the check less restrictive, but I scanned og.module and see = 1 and >= %d, while my database only has 1 for this value. Can this value every be anything besides 0 or 1?

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

looks fine now

Bevan’s picture

StatusFileSize
new1.55 KB

This version uses now-kinda-standard capital "OG" in the UI text.

Antinoo’s picture

I'm using OG 5.x-5.4 on Drupal 5.7, but it seems i cannot make these patches work. :(

user warning: Unknown column 'og_count' in 'order clause' query: SELECT DISTINCT(node.nid) FROM node node WHERE (node.type IN ('og_user_roles_subgroup','group')) ORDER BY og_count DESC LIMIT 0, 10 in includes/database.mysqli.inc on line 151.

og_count should be in the SELECT clause.
It seems that the $query->add_subquery() isn't called.
Only the ORDER BY clause is updated (maybe using that $query->orderby[], but I'm not sure the handler is called at all!).

I don't know how to make the patch work.
Some hours ago, I opened a topic forum at http://drupal.org/node/230773

douggreen’s picture

Did you remember to patch views with #143888?

Antinoo’s picture

I'm using drupal 5.7, og 5.x-5.4, views 5.x-1.6. Nothing is patched.

sites/all/modules/views> patch.exe -p0 -b < 143888_3.patch
patching file views.module
patching file views_cache.inc
patching file views_query.inc

sites/all/modules/og> patch.exe -p0 -b < 166244_2.patch
patching file og_views.inc
Hunk #1 succeeded at 250 (offset 10 lines).
Hunk #2 succeeded at 1304 (offset 10 lines).

It seems all goes patched ok.
But when I create a new view, the OG: Group: Subscriber Count field is still not sortable. :(

I'm a new Drupal user, should I make other things to apply the patch?
However, I'll try to retry with a fresh installation and to look into the code during the week.

mr.andrey’s picture

StatusFileSize
new244.57 KB

Hmmm... the patch seems to install fine, the option shows up under the Sort Criteria, but the sorting doesn't actually take place (see attached screenshots).

moshe weitzman’s picture

@mr. andrey - you have to patch Views and OG for this to work ... still waiting on Views for this.

mr.andrey’s picture

@moshe, ah, I see.

I tried to patch views with http://drupal.org/node/143888#comment-815243, which made no difference.

Thanks,
Andrey.

seth97’s picture

@mr.andrey

instead try the patch:
http://drupal.org/node/143888#comment-555015

mr.andrey’s picture

Ah, got it. That worked.

Is that patch eventually going to end up included in views? Do you know?

Thanks,
Andrey.

droople’s picture

Any news on this ??

I am desperate for this... I have no clue how to patch.

Can I have a patched VIews module and OG module

Thank you

Cheers

halfiranian’s picture

Just to confirm I've got it all working well with the latest two patches.

One thing to note: make sure you clear the cache (easy with the devel module) so that you can see the 'subscriber count' sort criteria after you've patched og_views.inc.

Droople, there's info on how to patch at: http://drupal.org/patch/apply

moshe weitzman’s picture

The real fix is under discussion at #336500: Og Statistics Module

moshe weitzman’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

Marking this is a dupe as I have no intention of committing it. Folks are welcome to use the patches here, of course.