NAME

CMS::Drupal::Modules::MembershipEntity::Stats - Generate statistics about MembershipEntity memberships on a Drupal site.

VERSION

version 0.95

SYNOPSIS

 use CMS::Drupal::Modules::MembershipEntity;
 use CMS::Drupal::Modules::MembershipEntity::Stats { into => 'CMS::Drupal::Modules::MembershipEntity' };
 
 my $ME = CMS::Drupal::Modules::MembershipEntity->new( dbh => $dbh ); 
 $ME->fetch_memberships();
 
 print $ME->count_active_memberships;
 print $ME->pct_active_memberships_were_renewal; 

 ...

DESCRIPTION

This module provides some basic statistical analysis about your Drupal site Memberships. It operates on the set of Memberships contained in $ME->{'_memberships'} in other words whichever ones you fetched with your call to $ME->fetch_memberships().

It has some methods for doing retroactive reporting on the DB records so you can initialize a reporting system with some statistical baselines.

See CMS::Drupal::Modules::MembershipEntity::Cookbook for more information and examples of usage.

METHODS

count_total_memberships( )

Returns the number of Memberships in the set.

count_expired_memberships( )

Returns the number of Memberships from the set that have status of 'expired'.

count_active_memberships( )

Returns the number of Memberships from the set that have status of 'active'.

count_cancelled_memberships( )

Returns the number of Memberships from the set that have status of 'cancelled'.

count_pending_memberships( )

Returns the number of Memberships from the set that have status of 'pending'.

count_set_were_renewal_memberships( )

Returns the number of Memberships from the set whose current Term was a renewal.

Dies if $ME->{'_memberships'} is not defined.

count_daily_were_renewal_memberships( @list_of_dates )

Returns the number of Memberships within the set that were renewals, i.e. whose currently active term was not the first term, on a given date, or range of dates. Takes a date-time or a range of date-times in ISO-ish format.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_term_expirations( @list_of_dates )

Returns the number of Membership Terms belonging to Members in the set that expired in the 24-hour period beginning with the date supplied. Takes dates in ISO-ish format.

Returns a scalar when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_term_activations( @list_of_dates )

Returns the number of Membership Terms belonging to Members in the set that began in the 24-hour period beginning with the date supplied. Takes dates in ISO-ish format.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_new_memberships( @list_of_dates )

Returns the number of Memberships in the set that were created in the 24-hour period beginning with the date supplied. Takes dates in ISO-ish format.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_new_terms( @list_of_dates )

Returns the number of Terms (belonging to Memberships in the set) that were created in the 24-hour period beginning with the date supplied.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_renewals( @list_of_dates )

Retruns the number of Membership Terms belonging to Memberships in the set that were created in the 24-hour period beginning with the date supplied and that were the second or subsequent Term belonging to that Membership.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

count_daily_active_memberships( @list_of_dates )

Returns the number of Memberships within the set with status of 'active' on a given date, or range of dates. Takes a date-time or a range of date-times in ISO-ish format.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of date-times.

Note that this report may not be 100% accurate, as data in the DB may have changed since a given date,particularly the status of Terms.

count_daily_total_memberships( @list_of_dates )

Returns the total number of Memberships (including those that have expired) that had been created by the end of the 24-hour period beginning with the datetime supplied.

Returns a scalar value when called with one date, or a hashref of counts indexed by dates, if called with an array of datetimes.

build_date_range( $datetime [, $datetime2] )

Builds a range of dates in ISO 8601 format. Takes dates in YYYY-MM-DD format. First date is the earliest date in the range. Second date is the latest date in the range: if omitted, this defaults to today's date. Returns an arrayref of datetime strings.

datetime_plus_one_day( $datetime )

Returns a timestamp representing the datetime one day after the datetime supplied.

time_plus_one_day( $datetime )

Returns a pair of epoch timestamps representing the datetime supplied and the datetime 24 hours later.

report_yesterday( [exclude => \@excluded_methods] )

This convenience method returns a hashref with the statistics from the day before today. If called with no arguments it returns data from all the count_daily_*() methods. Hashref returned includes the datetime used, indexed with 'date'.

Optionally takes an argument 'exclude', the value of which must be an anonymous array of method names you wish to exclude from the data returned.

AUTHOR

Nick Tonkin <tonkin@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Nick Tonkin.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.