CMS-Drupal-Modules-MembershipEntity

 view release on metacpan or  search on metacpan

lib/CMS/Drupal/Modules/MembershipEntity/Stats.pm  view on Meta::CPAN


  my $yesterday = DateTime->now()
                            ->clone()
                              ->subtract(days => 1)
                                ->set( hour => 0, minute => 0, second => 0 )
                                  ->datetime();
  
  my %data;

  for ( keys %methods ) {
    $data{ $_ } = $self->$_( $yesterday );
  }
  
  $data{ 'date' } = $yesterday;

  return \%data;

} # end sub


1; ## return true to end package CMS::Drupal::Modules::MembershipEntity

__END__

=pod

=encoding UTF-8

=head1 NAME

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

=head1 VERSION

version 0.96

=head1 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; 
 
  ...

=head1 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 L<CMS::Drupal::Modules::MembershipEntity::Cookbook|the Cookbook>
for more information and examples of usage.

=head1 METHODS

=head2 count_total_memberships( )

Returns the number of Memberships in the set.

=head2 count_expired_memberships( )

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

=head2 count_active_memberships( )

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

=head2 count_cancelled_memberships( )

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

=head2 count_pending_memberships( )

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

=head2 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.

=head2 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.

=head2 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.

=head2 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.

=head2 count_daily_new_memberships( @list_of_dates )



( run in 1.319 second using v1.01-cache-2.11-cpan-39bf76dae61 )