Hi there,

as opposed to the old OG6, it seems that in OG7 there are no simple statistics data about grups available or stored or views-enabled, such as "number of members", "number of group topics" -- i guess because it is not possible to supply statistics hard coded in og when the definitions and relations about what entitiy a group is and consists of is done at site-buidling-time (since og7 is so flexible with entities and fields as opposed to the old og6). Nevertheless, this data is needed in views for sorting by many og-usecases and people using og (in i guess 90% of all cases in the "standard" way of having group-nodes, group-posting-nodes with -comments, and member-users).

So,
1) did i get it right about the missing statistics data?
2) is there a current work-around, 3rd party module or best-practise for this?
3) are there any plans to support that or does anybody work on a og_statistics.module for OG7?
4) has anybody come around that in a quick-and-dorty way yet?

cheers,

daniel

Comments

idiotprayer’s picture

In the interest of possibly getting some collaboration on this, my initial port of the Organic Groups Statistics module is at http://drupal.org/sandbox/idiotprayer/1086720.
Much of it is not working, but a start is better than nothing?
Also, it was suggested that this module use fields for storage rather than its own table. I have another version (of which even less is working) which does that, but there were many areas where I couldn't figure out fields, eg. basics like hiding the field from the ui.
The big thing I couldn't figure out, and this precludes one essential - the 'number of members' - stat, is the fact that there is no longer a 'hook_og' in 7. I'm unable to work out what to use instead; whether a hook_field_update on the groups_audience field with logic is overthinking it and a bit heavy, whether there is an easy way to add new hook, etc.

ybthefurste’s picture

The sandbox module works for me, but I had to add the following inelegant redirect because the _og_statistics_user_stat2db (...) is mistakenly being called when a new group is created (line 248). I think that hook_user_update is being called before hook_node_insert. I can't really decipher that area, so inside _og_statistics_user_stat2db, after the $group=, I've added a check of the db to determine if a group with that nid exists; if it doesn't, abort the table update.

/**** START HACK ****/  
      $i=false;
      if ($result= db_query( "SELECT nid FROM {og_statistics} WHERE nid = :nid", array(':nid'=>$group->etid))) {
      	foreach( $result as $row ) { $i=true; }
      }
      // if results have been found, proceed.  Otherwise, the group hasn't yet been created
      if(!$i) { return; }  // leave.  don't perform user_update if group is brand new
/**** END HACK ****/  
g089h515r806’s picture

I need this feature too.

amitaibu’s picture

One solution, is you can have a field holding the members count, and with some custom code, populate it upon user join/ leave.

g089h515r806’s picture

It is a googd idea

playfulwolf’s picture

g089h515r806 - have you working example? I am working on the same problem and it seems that the way to build it with Rules is the best at the moment

joelpittet’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 7 reached end-of-life and the D7 version of Organic Groups is no longer being developed. To keep the issue queue focused on supported versions, we’re closing older D7 issues. If you still have questions about using Organic Groups on Drupal 7, feel free to ask. While we won’t fix D7 bugs anymore, we’re happy to offer guidance to help you move forward. You can do so by opening (or reopening) a D7 issue, or by reaching out in the #og channel on Drupal Slack.

If this issue is still relevant for Drupal 10+, please open a follow-up issue or merge request with proposed changes. Contributions are always welcome! 💙

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.