Skip to content

Commit

Permalink
WordCamp Counts: Add first time participation measurement (#935)
Browse files Browse the repository at this point in the history
* Get _wcb_volunteer_first_time value for volunteer

* Get _wcb_organizer_first_time value for organizer

* Get _wcb_speaker_first_time value for speaker

* Get _wcb_sponsor_first_time value for sponsor

* Get tix_first_time_attending_wp_event value for attendee

* Add first-time organizer/speaker/volunteer/attendee/sponsor data to the WordCamp count table

* Show n/a when it comes to sessions
  • Loading branch information
renintw authored Jul 26, 2023
1 parent 76de29c commit 20b1f38
Show file tree
Hide file tree
Showing 2 changed files with 188 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class WordCamp_Counts extends Base {
'post_id' => 0,
'type' => '',
'gender' => '',
'first_time' => '',
);

/**
Expand Down Expand Up @@ -276,6 +277,12 @@ public function get_data() {
public function compile_report_data( array $data ) {
$wordcamps = $this->prepare_data_for_display( $this->get_wordcamps() );

$first_time_template = array(
'yes' => 0,
'no' => 0,
'unsure' => 0,
);

$compiled_data = array(
'wordcamps' => array(),
'totals' => array(
Expand All @@ -284,12 +291,22 @@ public function compile_report_data( array $data ) {
'session' => 0,
'speaker' => 0,
'sponsor' => 0,
'volunteer' => 0,
),
'uniques' => array(
'attendee' => array(),
'organizer' => array(),
'speaker' => array(),
'sponsor' => array(),
'volunteer' => array(),
),
'first_times' => array(
'attendee' => $first_time_template,
'organizer' => $first_time_template,
'session' => $first_time_template,
'speaker' => $first_time_template,
'sponsor' => $first_time_template,
'volunteer' => $first_time_template,
),
);

Expand All @@ -300,6 +317,15 @@ public function compile_report_data( array $data ) {
'session' => 0,
'speaker' => 0,
'sponsor' => 0,
'volunteer' => 0,
),
'first_times' => array(
'attendee' => $first_time_template,
'organizer' => $first_time_template,
'session' => $first_time_template,
'speaker' => $first_time_template,
'sponsor' => $first_time_template,
'volunteer' => $first_time_template,
),
);

Expand All @@ -314,6 +340,7 @@ public function compile_report_data( array $data ) {
'attendee' => $gender_template,
'organizer' => $gender_template,
'speaker' => $gender_template,
'volunteer' => $gender_template,
);
}

Expand All @@ -331,9 +358,14 @@ public function compile_report_data( array $data ) {

$type = $item['type'];
$identifier = $item['identifier'];
$first_time = $item['first_time'];

$compiled_data['wordcamps'][ $wordcamp_id ]['totals'][ $type ] ++;
$compiled_data['totals'][ $type ] ++;
if ( isset( $wordcamp_template['first_times'][ $type ] ) ) {
$compiled_data['wordcamps'][ $wordcamp_id ]['first_times'][ $type ][ $first_time ] ++;
$compiled_data['first_times'][ $type ][ $first_time ] ++;
}
if ( isset( $compiled_data['uniques'][ $type ] ) ) {
$compiled_data['uniques'][ $type ][] = $identifier;
}
Expand Down Expand Up @@ -462,6 +494,7 @@ protected function get_data_for_site( $site_id, $wordcamp_id ) {
'post_id' => $attendee->ID,
'type' => 'attendee',
'identifier' => $attendee->tix_email,
'first_time' => $attendee->tix_first_time_attending_wp_event,
);

if ( $this->include_gender ) {
Expand All @@ -486,6 +519,7 @@ protected function get_data_for_site( $site_id, $wordcamp_id ) {
'post_id' => $organizer->ID,
'type' => 'organizer',
'identifier' => $organizer->_wcpt_user_id,
'first_time' => $organizer->_wcb_organizer_first_time,
);

if ( $this->include_gender ) {
Expand Down Expand Up @@ -540,6 +574,7 @@ protected function get_data_for_site( $site_id, $wordcamp_id ) {
'post_id' => $speaker->ID,
'type' => 'speaker',
'identifier' => $speaker->_wcb_speaker_email,
'first_time' => $speaker->_wcb_speaker_first_time,
);

if ( $this->include_gender ) {
Expand All @@ -564,6 +599,7 @@ protected function get_data_for_site( $site_id, $wordcamp_id ) {
'post_id' => $sponsor->ID,
'type' => 'sponsor',
'identifier' => $this->get_sponsor_identifier( $sponsor->_wcpt_sponsor_website ),
'first_time' => $sponsor->_wcb_sponsor_first_time,
);

if ( $this->include_gender ) {
Expand All @@ -575,6 +611,31 @@ protected function get_data_for_site( $site_id, $wordcamp_id ) {
clean_post_cache( $sponsor );
}

$volunteers = new WP_Query( array(
'posts_per_page' => -1,
'post_type' => 'wcb_volunteer',
'post_status' => 'publish',
) );

foreach ( $volunteers->posts as $volunteer ) {
$data = array(
'wordcamp_id' => $wordcamp_id,
'site_id' => $site_id,
'post_id' => $volunteer->ID,
'type' => 'volunteer',
'identifier' => $volunteer->_wcpt_user_name,
'first_time' => $volunteer->_wcb_volunteer_first_time,
);

if ( $this->include_gender ) {
$data['first_name'] = explode( ' ', $volunteer->post_title )[0];
}

$site_data[] = $data;

clean_post_cache( $volunteer );
}

restore_current_blog();

// Convert blanks to unique values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
/** @var DateTime $end_date */
/** @var string $statuses */

$gender_legend = '<span class="description small"><span class="total">Total</span> / F / M / ?</span>';
$gender_legend = '<span class="description small">Gender: F / M / ?</span>';
$first_time_legend = '<span class="description small">Y / N / ?</span>';

?>

Expand All @@ -35,38 +36,71 @@
</tr>
</table>

<h4>Totals and Uniques</h4>
<h4>Totals, Uniques and First times</h4>

<table class="striped widefat but-not-too-wide">
<tr>
<td>Type</td>
<td>Total</td>
<td>Unique</td>
<td>First time<br><?php echo $first_time_legend; ?></td>
</tr>
<tr>
<td>Registered Attendees</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['attendee'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['uniques']['attendee'] ); ?></td>
<td class="number">
<?php echo number_format_i18n( $data['first_times']['attendee']['yes'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['attendee']['no'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['attendee']['unsure'] ); ?>
</td>
</tr>
<tr>
<td>Organizers</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['organizer'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['uniques']['organizer'] ); ?></td>
<td class="number">
<?php echo number_format_i18n( $data['first_times']['organizer']['yes'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['organizer']['no'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['organizer']['unsure'] ); ?>
</td>
</tr>
<tr>
<td>Sessions</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['session'] ); ?></td>
<td class="number">n/a</td>
<td class="number">n/a</td>
</tr>
<tr>
<td>Speakers</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['speaker'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['uniques']['speaker'] ); ?></td>
<td class="number">
<?php echo number_format_i18n( $data['first_times']['speaker']['yes'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['speaker']['no'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['speaker']['unsure'] ); ?>
</td>
</tr>
<tr>
<td>Sponsors</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['sponsor'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['uniques']['sponsor'] ); ?></td>
<td class="number">
<?php echo number_format_i18n( $data['first_times']['sponsor']['yes'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['sponsor']['no'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['sponsor']['unsure'] ); ?>
</td>
</tr>

<tr>
<td>Volunteers</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['volunteer'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['uniques']['volunteer'] ); ?></td>
<td class="number">
<?php echo number_format_i18n( $data['first_times']['volunteer']['yes'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['volunteer']['no'] ); ?>
/ <?php echo number_format_i18n( $data['first_times']['volunteer']['unsure'] ); ?>
</td>
</tr>
</table>

Expand Down Expand Up @@ -102,6 +136,14 @@
<td class="number"><?php echo number_format_i18n( $data['genders']['speaker']['male'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['genders']['speaker']['unknown'] ); ?></td>
</tr>

<tr>
<td>Volunteers</td>
<td class="number"><?php echo number_format_i18n( $data['totals']['volunteer'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['genders']['volunteer']['female'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['genders']['volunteer']['male'] ); ?></td>
<td class="number"><?php echo number_format_i18n( $data['genders']['volunteer']['unknown'] ); ?></td>
</tr>
</table>
<?php endif; ?>

Expand All @@ -112,11 +154,49 @@
<td>WordCamp</td>
<td>Date</td>
<td>Status</td>
<td>Registered Attendees<?php if ( ! empty( $data['genders'] ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
<td>Organizers<?php if ( ! empty( $data['genders'] ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
<td>Registered Attendees
<br>
<span class="description small">First time: </span>
<?php echo $first_time_legend; ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
<br />
<?php echo $gender_legend; ?>
<?php endif; ?>
</td>
<td>Organizers
<br>
<span class="description small">First time: </span>
<?php echo $first_time_legend; ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
<br />
<?php echo $gender_legend; ?>
<?php endif; ?>
</td>
<td>Sessions</td>
<td>Speakers<?php if ( ! empty( $data['genders'] ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
<td>Sponsors</td>
<td>Speakers
<br>
<span class="description small">First time: </span>
<?php echo $first_time_legend; ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
<br />
<?php echo $gender_legend; ?>
<?php endif; ?>
</td>
<td>Sponsors
<br>
<span class="description small">First time: </span>
<?php echo $first_time_legend; ?>
</td>
<td>
Volunteers
<br>
<span class="description small">First time: </span>
<?php echo $first_time_legend; ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
<br>
<?php echo $gender_legend; ?>
<?php endif; ?>
</td>
</tr>

<?php foreach ( $data['wordcamps'] as $event ) : ?>
Expand All @@ -126,18 +206,28 @@
<td><?php echo esc_html( $event['info']['Status'] ); ?></td>

<td class="number">
<span class="total"><?php echo number_format_i18n( $event['totals']['attendee'] ); ?></span>
<span class="total">Total: <?php echo number_format_i18n( $event['totals']['attendee'] ); ?></span>
<br>
FT: <?php echo number_format_i18n( $event['first_times']['attendee']['yes'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['attendee']['no'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['attendee']['unsure'] ); ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
/ <?php echo number_format_i18n( $event['genders']['attendee']['female'] ); ?>
<br>
G: <?php echo number_format_i18n( $event['genders']['attendee']['female'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['attendee']['male'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['attendee']['unknown'] ); ?>
<?php endif; ?>
</td>

<td class="number">
<span class="total"><?php echo number_format_i18n( $event['totals']['organizer'] ); ?></span>
<span class="total">Total: <?php echo number_format_i18n( $event['totals']['organizer'] ); ?></span>
<br>
FT: <?php echo number_format_i18n( $event['first_times']['organizer']['yes'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['organizer']['no'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['organizer']['unsure'] ); ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
/ <?php echo number_format_i18n( $event['genders']['organizer']['female'] ); ?>
<br>
G: <?php echo number_format_i18n( $event['genders']['organizer']['female'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['organizer']['male'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['organizer']['unknown'] ); ?>
<?php endif; ?>
Expand All @@ -148,16 +238,39 @@
</td>

<td class="number">
<span class="total"><?php echo number_format_i18n( $event['totals']['speaker'] ); ?></span>
<span class="total">Total: <?php echo number_format_i18n( $event['totals']['speaker'] ); ?></span>
<br>
FT: <?php echo number_format_i18n( $event['first_times']['speaker']['yes'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['speaker']['no'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['speaker']['unsure'] ); ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
/ <?php echo number_format_i18n( $event['genders']['speaker']['female'] ); ?>
<br>
G: <?php echo number_format_i18n( $event['genders']['speaker']['female'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['speaker']['male'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['speaker']['unknown'] ); ?>
<?php endif; ?>
</td>

<td class="number total">
<?php echo number_format_i18n( $event['totals']['sponsor'] ); ?>
<td class="number">
<span class="total">Total: <?php echo number_format_i18n( $event['totals']['sponsor'] ); ?></span>
<br>
FT: <?php echo number_format_i18n( $event['first_times']['sponsor']['yes'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['sponsor']['no'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['sponsor']['unsure'] ); ?>
</td>

<td class="number">
<span class="total">Total: <?php echo number_format_i18n( $event['totals']['volunteer'] ); ?></span>
<br>
FT: <?php echo number_format_i18n( $event['first_times']['volunteer']['yes'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['volunteer']['no'] ); ?>
/ <?php echo number_format_i18n( $event['first_times']['volunteer']['unsure'] ); ?>
<?php if ( ! empty( $data['genders'] ) ) : ?>
<br>
G: <?php echo number_format_i18n( $event['genders']['volunteer']['female'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['volunteer']['male'] ); ?>
/ <?php echo number_format_i18n( $event['genders']['volunteer']['unknown'] ); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down

0 comments on commit 20b1f38

Please sign in to comment.