I would like to see both sort handlers for members_count and post_count so groups can be sorted by it, which is a very sensible feature.

i would like to write the class but i can't find documentation how to add_orderby but not just a field

If you have a tip i would write the patch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
5.58 KB

This patch adds a sort handler for

- count members
- posts
- new posts

Sponsored by erdfisch

moshe weitzman’s picture

Status: Needs review » Needs work

I'm concerned about the performance of this. I know we use subqueries in the field definition but sorting by a subquery is even worse for performance. We really need to introduce a summary table for each group which holds a sum of posts and members. Like node_comment_statistics.

dawehner’s picture

Brainstorm:

Table: og_statistics
Field:

  • nid
  • count_members:
    How many members does the group has
  • count_posts:
    How many posts are in this group
  • count_comments:
    Counts the comments in the group
    // not really important i think
  • last_node_timestamp:
    When was the last node created/changed in the group
  • last_user_timestamp:
    When did the last user joined the group
  • last_comment_timestamp:
    When was the last comment created on one of the nodes in the group

Additional/ other ideas?

moshe weitzman’s picture

Those fields look very nice.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.2 KB

so i created a scheme definition for this data

dawehner’s picture

FileSize
8.19 KB

so i managed to write this module

i created also some tests, but the fail, even real world using works well, as far as i testet it

very important the views integration is only started yet, but it works

this is a tar.gz which should be placed into og/modules/ because CVS cannot add dirs for patches

dawehner’s picture

Title: Sort Handler for Members Count and Post Count » Og Statistics Module

updated code:

much more views integration

fixed bug in the update handling

Changed title

Anyone want to review test?

ekes’s picture

Hi, cheers for this. I was just about to write a simple module to make a table of statistics for og on a site! And found this, it's the great thing about Drupal, so often someone has already thought about it. Anyway this site's Drupal 5 so I've backported your work - and extended it a bit.

Big notes:

  • Deleting nodes with comments on them is going to mess up the comment count. See the note in the hook_nodeapi() code.
  • I've added code to the hook_nodeapi($op = 'update') because groups can be added or removed from a node at this stage.
  • You need a set / reset function especially if this is going into live sites that already have groups. I've written one, but it needs a UI - just a menu item I guess - see og_statistics_reset() comment.

Smaller notes.

  • There were a couple of calls in the code that had the wrong arguments. If you run a diff on the d5 and d6 versions you'll probably notice them.
  • I changed the field names to make them more consistent with node_comment_statistics
  • The D5 version extensions I put on it were a whole load more views filters, fields, sorts; and a bit of a hackish change for faceted_search to allow for sorting results on when nodes in groups were updated.

If I get time, which I'm not sure I will I'm afraid, I'll port my changes back to the D6 version. The biggy that's still there is still the deleting nodes with comments thing though.

Ah the code is in my sandbox: http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/ekes/og_sta...

moshe weitzman’s picture

Status: Needs review » Needs work

Seems like there is not a complete version for d6 yet.

dawehner’s picture

Status: Needs work » Needs review
FileSize
3.49 KB

here is a new version, which merges the stuff from ekes into the d6 version.

@TODO: writing tests for all functionality.

bernland’s picture

I added that folder to og/modules and the module "Organic groups statistics" shows up on the modules page. However, I can't enable it because of:

Depends on: Array (missing)

Any ideas?

dawehner’s picture

FileSize
3.46 KB

quite strange.

btw here is the new version

if you want to have the newest version you could also try out using https://code.launchpad.net/~dereine/+junk/og_statistics

bernland’s picture

Ok. I just downloaded the latest version and changed

dependencies[] = og
dependencies[] = og_views

to

dependencies = og og_views

in og_statistics.info, now the status line reads

Depends on: Organic groups (enabled), Og_views (missing)

How do I install og_views???

dawehner’s picture

my version of the module is for drupal6, therefore the Version is set to HEAD.

moshe weitzman’s picture

Status: Needs review » Closed (works as designed)

I'd be really pleased if this lived in Contrib on its own for a while so the bugs get shaken out and we learn how popular it is. I'm not planning on taking it into og itself just yet. I do think it is very valuable.

dawehner’s picture

i created a project for this

http://drupal.org/project/og_statistics

i would like to have more feedback tests etc.

squinternata’s picture

more idea for og_statistics

counter for member daily visits to the community.
thanks
A
someone asked me :)