From 20b1f38922f601e805d196a00208ffa7640f50fb Mon Sep 17 00:00:00 2001 From: Ren <18050944+renintw@users.noreply.github.com> Date: Wed, 26 Jul 2023 17:50:22 +0800 Subject: [PATCH] WordCamp Counts: Add first time participation measurement (#935) * 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 --- .../classes/report/class-wordcamp-counts.php | 61 ++++++++ .../views/html/wordcamp-counts.php | 141 ++++++++++++++++-- 2 files changed, 188 insertions(+), 14 deletions(-) diff --git a/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php b/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php index 397e03bad..3595d9bc8 100644 --- a/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php +++ b/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php @@ -130,6 +130,7 @@ class WordCamp_Counts extends Base { 'post_id' => 0, 'type' => '', 'gender' => '', + 'first_time' => '', ); /** @@ -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( @@ -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, ), ); @@ -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, ), ); @@ -314,6 +340,7 @@ public function compile_report_data( array $data ) { 'attendee' => $gender_template, 'organizer' => $gender_template, 'speaker' => $gender_template, + 'volunteer' => $gender_template, ); } @@ -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; } @@ -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 ) { @@ -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 ) { @@ -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 ) { @@ -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 ) { @@ -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. diff --git a/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php b/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php index b65e33842..7b5c02ac1 100644 --- a/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php +++ b/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php @@ -14,7 +14,8 @@ /** @var DateTime $end_date */ /** @var string $statuses */ -$gender_legend = 'Total / F / M / ?'; +$gender_legend = 'Gender: F / M / ?'; +$first_time_legend = 'Y / N / ?'; ?> @@ -35,38 +36,71 @@ -

Totals and Uniques

+

Totals, Uniques and First times

+ + + + + + + + + + + + +
Type Total UniqueFirst time
Registered Attendees + + / + / +
Organizers + + / + / +
Sessions n/an/a
Speakers + + / + / +
Sponsors + + / + / +
Volunteers + + / + / +
@@ -102,6 +136,14 @@ + + + Volunteers + + + + + @@ -112,11 +154,49 @@ WordCamp Date Status - Registered Attendees
- Organizers
+ Registered Attendees +
+ First time: + + +
+ + + + Organizers +
+ First time: + + +
+ + + Sessions - Speakers
- Sponsors + Speakers +
+ First time: + + +
+ + + + Sponsors +
+ First time: + + + + Volunteers +
+ First time: + + +
+ + + @@ -126,18 +206,28 @@ - + Total: +
+ FT: + / + / - / +
+ G: / / - + Total: +
+ FT: + / + / - / +
+ G: / / @@ -148,16 +238,39 @@ - + Total: +
+ FT: + / + / - / +
+ G: / / - - + + Total: +
+ FT: + / + / + + + + Total: +
+ FT: + / + / + +
+ G: + / + / +