<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[7912] sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports: WordCamp Reports: Refactor WordCamp Counts for better data caching</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://meta.trac.wordpress.org/changeset/7912">7912</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/7912","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>coreymckrill</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2018-11-28 22:47:15 +0000 (Wed, 28 Nov 2018)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>WordCamp Reports: Refactor WordCamp Counts for better data caching
This separates the data gathering so that `get_data` only handles the "raw"
rows of data that could be exported to a CSV, while `compile_report_data`
handles the counting of totals, uniques, etc. This also streamlines the
gender estimation process so that the API client is only used once per site.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsclassesreportclasswordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewshtmlwordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php</a></li>
<li><a href="#sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewsreportwordcampcountsphp">sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsclassesreportclasswordcampcountsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php 2018-11-28 02:17:30 UTC (rev 7911)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php 2018-11-28 22:47:15 UTC (rev 7912)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -24,6 +24,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WordCamp_Counts extends Base {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The lowest acceptable probability when determining gender.
+ *
+ * @var float
+ */
+ const GENDER_PROBABILITY_THRESHOLD = 0.9;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Report name.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var string
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,24 +112,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected $genderize = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * An array of data from the WordCamp Details report.
+ *
+ * @var array|null
+ */
+ protected $wordcamps = null;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Data fields that can be visible in a public context.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var array An associative array of key/default value pairs.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $public_data_fields = [
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ID' => 0,
- 'Name' => '',
- 'URL' => '',
- 'Start Date (YYYY-mm-dd)' => '',
- 'Status' => '',
- 'attendees' => 0,
- 'organizers' => 0,
- 'sessions' => 0,
- 'speakers' => 0,
- 'sponsors' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wordcamp_id' => 0,
+ 'site_id' => 0,
+ 'post_id' => 0,
+ 'type' => '',
+ 'gender' => '',
</ins><span class="cx" style="display: block; padding: 0 10px"> ];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Data fields that should only be visible in a private context.
+ *
+ * @var array An associative array of key/default value pairs.
+ */
+ protected $private_data_fields = [
+ 'identifier' => '',
+ ];
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * WordCamp_Counts constructor.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $start_date The start of the date range for the report.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,9 +218,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Query and parse the data for the report.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * TODO Refactor the raw data structure to make it exportable as a CSV, move some of the counting stuff
- * to compile_report_data().
- *
</del><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_data() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -217,47 +232,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $data;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // @todo Maybe find a way to run this without having to hack the memory limit.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // @todo Maybe find a way to run this without having to hack the ini.
</ins><span class="cx" style="display: block; padding: 0 10px"> ini_set( 'memory_limit', '900M' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ini_set( 'max_execution_time', 300 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $details_options = [
- 'public' => false,
- ];
- $details_report = new WordCamp_Details( $this->range, [], false, $details_options );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wordcamps = $this->get_wordcamps();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $details_report->error->get_error_messages() ) ) {
- $this->error = $this->merge_errors( $this->error, $details_report->error );
-
- return [];
- }
-
- $wordcamps = array_filter( $details_report->get_data(), function( $wordcamp ) {
- // Skip camps with no website URL.
- if ( ! $wordcamp['URL'] ) {
- return false;
- }
-
- if ( ! empty( $this->statuses ) && ! in_array( $wordcamp['Status'], $this->statuses ) ) {
- return false;
- }
-
- return true;
- } );
-
- $wordcamps = array_reduce( $wordcamps, function( $carry, $item ) {
- $keep = [
- 'ID' => '',
- 'Name' => '',
- 'URL' => '',
- 'Start Date (YYYY-mm-dd)' => '',
- 'Status' => '',
- ];
-
- $carry[ $item['ID'] ] = array_intersect_key( $item, $keep );
-
- return $carry;
- }, [] );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $wordcamp_ids = array_keys( $wordcamps );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = [];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -266,98 +246,112 @@
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> $valid = validate_wordcamp_id( $wordcamp_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data[ $wordcamp_id ] = array_merge(
- $wordcamps[ $wordcamp_id ],
- $this->get_data_for_site( $valid->site_id )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = array_merge( $data, $this->get_data_for_site( $valid->site_id, $valid->post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } catch ( Exception $e ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->error->add(
</span><span class="cx" style="display: block; padding: 0 10px"> self::$slug . '-wordcamp-id-error',
</span><span class="cx" style="display: block; padding: 0 10px"> $e->getMessage()
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->error->get_error_messages() ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $totals = [
- 'attendees' => 0,
- 'organizers' => 0,
- 'sessions' => 0,
- 'speakers' => 0,
- 'sponsors' => 0,
- ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = $this->filter_data_fields( $data );
+ $this->maybe_cache_data( $data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $uniques = [
- 'attendees' => [],
- 'organizers' => [],
- 'speakers' => [],
- 'sponsors' => [],
- ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $data;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $gender_template = [
- 'female' => 0,
- 'male' => 0,
- 'unknown' => 0,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Compile the report data into results.
+ *
+ * @param array $data The data to compile.
+ *
+ * @return array
+ */
+ public function compile_report_data( array $data ) {
+ $wordcamps = $this->prepare_data_for_display( $this->get_wordcamps() );
+
+ $compiled_data = [
+ 'wordcamps' => [],
+ 'totals' => [
+ 'attendee' => 0,
+ 'organizer' => 0,
+ 'session' => 0,
+ 'speaker' => 0,
+ 'sponsor' => 0,
+ ],
+ 'uniques' => [
+ 'attendee' => [],
+ 'organizer' => [],
+ 'speaker' => [],
+ 'sponsor' => [],
+ ],
</ins><span class="cx" style="display: block; padding: 0 10px"> ];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $genders = [
- 'attendees' => $gender_template,
- 'organizers' => $gender_template,
- 'speakers' => $gender_template,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wordcamp_template = [
+ 'totals' => [
+ 'attendee' => 0,
+ 'organizer' => 0,
+ 'session' => 0,
+ 'speaker' => 0,
+ 'sponsor' => 0,
+ ],
</ins><span class="cx" style="display: block; padding: 0 10px"> ];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $data as $id => &$event ) {
- foreach ( $totals as $key => $bucket ) {
- if ( isset( $uniques[ $key ] ) ) {
- $uniques[ $key ] = array_unique( array_merge( $uniques[ $key ], $event[ $key ]['total'] ) );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $gender_template = [
+ 'female' => 0,
+ 'male' => 0,
+ 'unknown' => 0,
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->include_gender && isset( $genders[ $key ] ) ) {
- $event[ $key ]['gender'] = array_reduce( $event[ $key ]['gender'], function( $carry, $item ) {
- $carry[ $item ] ++;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $wordcamp_template['genders'] = $compiled_data['genders'] = [
+ 'attendee' => $gender_template,
+ 'organizer' => $gender_template,
+ 'speaker' => $gender_template,
+ ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $carry;
- }, $gender_template );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $data as $item ) {
+ $wordcamp_id = $item['wordcamp_id'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $genders[ $key ] as $gender => &$total ) {
- $total += $event[ $key ]['gender'][ $gender ];
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! isset( $compiled_data['wordcamps'][ $wordcamp_id ] ) ) {
+ $compiled_data['wordcamps'][ $wordcamp_id ] = array_merge(
+ [
+ 'info' => $wordcamps[ $wordcamp_id ],
+ ],
+ $wordcamp_template
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $event[ $key ]['total'] = count( $event[ $key ]['total'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $type = $item['type'];
+ $identifier = $item['identifier'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $totals[ $key ] += $event[ $key ]['total'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $compiled_data['wordcamps'][ $wordcamp_id ]['totals'][ $type ] ++;
+ $compiled_data['totals'][ $type ] ++;
+ if ( isset( $compiled_data['uniques'][ $type ] ) ) {
+ $compiled_data['uniques'][ $type ][] = $identifier;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data['totals'] = $totals;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender && isset( $wordcamp_template['genders'][ $type ] ) ) {
+ $gender = $item['gender'];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data['uniques'] = array_map( function( $group ) {
- return count( $group );
- }, $uniques );
-
- if ( $this->include_gender ) {
- $data['genders'] = $genders;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $compiled_data['wordcamps'][ $wordcamp_id ]['genders'][ $type ][ $gender ] ++;
+ $compiled_data['genders'][ $type ][ $gender ] ++;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data = $this->filter_data_fields( $data );
- $this->maybe_cache_data( $data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $compiled_data['uniques'] = array_map( function( $group ) {
+ $group = array_unique( $group );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $data;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return count( $group );
+ }, $compiled_data['uniques'] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /**
- * Compile the report data into results.
- *
- * TODO Move some of the logic from get_data into here.
- *
- * @param array $data The data to compile.
- *
- * @return array
- */
- public function compile_report_data( array $data ) {
- return $data;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $compiled_data;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -387,26 +381,69 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Get data from a WordCamp Details report and filter it.
+ *
+ * @return array|null
+ */
+ protected function get_wordcamps() {
+ if ( is_array( $this->wordcamps ) ) {
+ return $this->wordcamps;
+ }
+
+ $details_options = [
+ 'public' => false,
+ ];
+ $details_report = new WordCamp_Details( $this->range, [], false, $details_options );
+
+ if ( ! empty( $details_report->error->get_error_messages() ) ) {
+ $this->error = $this->merge_errors( $this->error, $details_report->error );
+
+ return [];
+ }
+
+ $wordcamps = array_filter( $details_report->get_data(), function( $wordcamp ) {
+ // Skip camps with no website URL.
+ if ( ! $wordcamp['URL'] ) {
+ return false;
+ }
+
+ if ( ! empty( $this->statuses ) && ! in_array( $wordcamp['Status'], $this->statuses ) ) {
+ return false;
+ }
+
+ return true;
+ } );
+
+ $this->wordcamps = array_reduce( $wordcamps, function( $carry, $item ) {
+ $keep = [
+ 'ID' => '',
+ 'Name' => '',
+ 'URL' => '',
+ 'Start Date (YYYY-mm-dd)' => '',
+ 'Status' => '',
+ ];
+
+ $carry[ $item['ID'] ] = array_intersect_key( $item, $keep );
+
+ return $carry;
+ }, [] );
+
+ return $this->wordcamps;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Retrieve all of the data for one site.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $site_id
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $wordcamp_id
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function get_data_for_site( $site_id ) {
- $site_data = [
- 'attendees' => [],
- 'organizers' => [],
- 'sessions' => [],
- 'speakers' => [],
- 'sponsors' => [],
- ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function get_data_for_site( $site_id, $wordcamp_id ) {
+ $site_data = [];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> switch_to_blog( $site_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // The get_locale() function doesn't work inside switch_to_blog because it returns early.
- $wp_locale = get_site_option( 'WPLANG', 'en_US' );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $attendees = new WP_Query( [
</span><span class="cx" style="display: block; padding: 0 10px"> 'posts_per_page' => -1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'tix_attendee',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -413,14 +450,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['attendees']['total'] = wp_list_pluck( $attendees->posts, 'tix_email', 'ID' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $attendees->posts as $attendee ) {
+ $data = [
+ 'wordcamp_id' => $wordcamp_id,
+ 'site_id' => $site_id,
+ 'post_id' => $attendee->ID,
+ 'type' => 'attendee',
+ 'identifier' => $attendee->tix_email,
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->include_gender ) {
- $names = array_map( function( $name ) {
- return explode( ' ', $name )[0];
- }, wp_list_pluck( $attendees->posts, 'tix_first_name', 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $data['first_name'] = explode( ' ', $attendee->tix_first_name )[0];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['attendees']['gender'] = $this->get_genders( $names, $wp_locale );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_data[] = $data;
+
+ clean_post_cache( $attendee );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $organizers = new WP_Query( [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -429,30 +474,54 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['organizers']['total'] = wp_list_pluck( $organizers->posts, '_wcpt_user_id', 'ID' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $organizers->posts as $organizer ) {
+ $data = [
+ 'wordcamp_id' => $wordcamp_id,
+ 'site_id' => $site_id,
+ 'post_id' => $organizer->ID,
+ 'type' => 'organizer',
+ 'identifier' => $organizer->_wcpt_user_id,
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->include_gender ) {
- $names = array_map( function( $name ) {
- return explode( ' ', $name )[0];
- }, wp_list_pluck( $organizers->posts, 'post_title', 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $data['first_name'] = explode( ' ', $organizer->post_title )[0];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['organizers']['gender'] = $this->get_genders( $names, $wp_locale );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_data[] = $data;
+
+ clean_post_cache( $organizer );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $sessions = new WP_Query( [
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'posts_per_page' => - 1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'posts_per_page' => -1,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'wcb_session',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'meta_query' => [
</span><span class="cx" style="display: block; padding: 0 10px"> [
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => '_wcpt_session_type',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => 'session',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => 'session', // Other session types are usually things like "Lunch".
</ins><span class="cx" style="display: block; padding: 0 10px"> ]
</span><span class="cx" style="display: block; padding: 0 10px"> ],
</span><span class="cx" style="display: block; padding: 0 10px"> ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['sessions']['total'] = wp_list_pluck( $sessions->posts, 'ID' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $sessions->posts as $session ) {
+ $data = [
+ 'wordcamp_id' => $wordcamp_id,
+ 'site_id' => $site_id,
+ 'post_id' => $session->ID,
+ 'type' => 'session',
+ 'identifier' => '',
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $data['first_name'] = '';
+ }
+
+ $site_data[] = $data;
+
+ clean_post_cache( $session );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $speakers = new WP_Query( [
</span><span class="cx" style="display: block; padding: 0 10px"> 'posts_per_page' => -1,
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'wcb_speaker',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -459,14 +528,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['speakers']['total'] = wp_list_pluck( $speakers->posts, '_wcb_speaker_email', 'ID' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $speakers->posts as $speaker ) {
+ $data = [
+ 'wordcamp_id' => $wordcamp_id,
+ 'site_id' => $site_id,
+ 'post_id' => $speaker->ID,
+ 'type' => 'speaker',
+ 'identifier' => $speaker->_wcb_speaker_email,
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->include_gender ) {
- $names = array_map( function( $name ) {
- return explode( ' ', $name )[0];
- }, wp_list_pluck( $speakers->posts, 'post_title', 'ID' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $data['first_name'] = explode( ' ', $speaker->post_title )[0];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['speakers']['gender'] = $this->get_genders( $names, $wp_locale );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_data[] = $data;
+
+ clean_post_cache( $speaker );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $sponsors = new WP_Query( [
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -475,32 +552,62 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> ] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $site_data['sponsors']['total'] = array_map( function( $url ) {
- $hostname = wp_parse_url( $url, PHP_URL_HOST );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $sponsors->posts as $sponsor ) {
+ $data = [
+ 'wordcamp_id' => $wordcamp_id,
+ 'site_id' => $site_id,
+ 'post_id' => $sponsor->ID,
+ 'type' => 'sponsor',
+ 'identifier' => $this->get_sponsor_identifier( $sponsor->_wcpt_sponsor_website ),
+ ];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $hostname ) {
- return '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->include_gender ) {
+ $data['first_name'] = '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $trimmed = substr( $hostname, 0, strripos( $hostname, '.' ) ); // Remove the TLD.
- $trimmed = preg_replace( '/\.com?$/', '', $trimmed ); // Remove possible secondary .com or .co.
- $trimmed = preg_replace( '/^www\./', '', $trimmed ); // Remove possible www.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $site_data[] = $data;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $trimmed;
- }, wp_list_pluck( $sponsors->posts, '_wcpt_sponsor_website' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ clean_post_cache( $sponsor );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> restore_current_blog();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $site_data as $type => &$data ) {
- if ( 'sessions' === $type ) {
- continue;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Convert blanks to unique values.
+ array_walk( $site_data, function( &$value ) {
+ if ( 'session' === $value['type'] ) {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Convert blanks to unique values.
- array_walk( $data['total'], function( &$value, $key ) use ( $site_id ) {
- if ( ! $value ) {
- $value = "{$site_id}_{$key}";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $value['identifier'] ) ) {
+ $value['identifier'] = "{$value['site_id']}_{$value['post_id']}";
+ }
+ } );
+
+ if ( $this->include_gender ) {
+ $names = array_filter( wp_list_pluck( $site_data, 'first_name' ) );
+
+ // The get_locale() function doesn't work inside switch_to_blog because it returns early.
+ $wp_locale = get_site_option( 'WPLANG', 'en_US' );
+
+ $gender_data = $this->genderize->get_gender_data( $names, $wp_locale );
+
+ if ( ! empty( $this->genderize->error->get_error_messages() ) ) {
+ $this->merge_errors( $this->error, $this->genderize->error );
+
+ return [];
+ }
+
+ array_walk( $site_data, function( &$value ) use ( $gender_data ) {
+ $name = strtolower( $value['first_name'] );
+ $data = $gender_data[ $name ];
+
+ if ( ! $data['gender'] || $data['probability'] < self::GENDER_PROBABILITY_THRESHOLD ) {
+ $value['gender'] = 'unknown';
+ } else {
+ $value['gender'] = $data['gender'];
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ unset( $value['first_name'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -508,39 +615,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Try to detect the genders for a list of first names.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reduce a sponsor URL to a simple domain name with no TLD.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param array $names
- * @param string $locale
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $sponsor_url
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected function get_genders( $names, $locale ) {
- $probability_threshold = (float) 0.9;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected function get_sponsor_identifier( $sponsor_url ) {
+ $hostname = wp_parse_url( $sponsor_url, PHP_URL_HOST );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $names = array_map( 'strtolower', $names );
- $genders = [];
-
- $gender_data = $this->genderize->get_gender_data( $names, $locale );
-
- if ( ! empty( $this->genderize->error->get_error_messages() ) ) {
- $this->merge_errors( $this->error, $this->genderize->error );
-
- return [];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! $hostname ) {
+ return '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $names as $name ) {
- $data = $gender_data[ $name ];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $trimmed = substr( $hostname, 0, strripos( $hostname, '.' ) ); // Remove the TLD.
+ $trimmed = preg_replace( '/\.com?$/', '', $trimmed ); // Remove possible secondary .com or .co.
+ $trimmed = preg_replace( '/^www\./', '', $trimmed ); // Remove possible www.
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $data['gender'] || $data['probability'] < $probability_threshold ) {
- $genders[] = 'unknown';
- continue;
- }
-
- $genders[] = $data['gender'];
- }
-
- return $genders;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $trimmed;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -549,18 +641,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return void
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function render_html() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $data = $this->prepare_data_for_display( $this->get_data() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $data = $this->compile_report_data( $this->get_data() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $start_date = $this->range->start;
</span><span class="cx" style="display: block; padding: 0 10px"> $end_date = $this->range->end;
</span><span class="cx" style="display: block; padding: 0 10px"> $statuses = $this->statuses;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->include_gender ) {
- $genders = array_pop( $data );
- }
-
- $uniques = array_pop( $data );
- $totals = array_pop( $data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->error->get_error_messages() ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->render_error_html();
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -591,7 +676,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> && current_user_can( 'manage_network' )
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $options = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'public' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'public' => false,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'max_interval' => new DateInterval( 'P1Y1M' ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewshtmlwordcampcountsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php 2018-11-28 02:17:30 UTC (rev 7911)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/html/wordcamp-counts.php 2018-11-28 22:47:15 UTC (rev 7912)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -8,20 +8,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> use DateTime;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/** @var array $data */
</ins><span class="cx" style="display: block; padding: 0 10px"> /** @var DateTime $start_date */
</span><span class="cx" style="display: block; padding: 0 10px"> /** @var DateTime $end_date */
</span><span class="cx" style="display: block; padding: 0 10px"> /** @var string $statuses */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/** @var array $data */
-/** @var array $totals */
-/** @var array $uniques */
-/** @var array $genders */
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $gender_legend = '<span class="description small"><span class="total">Total</span> / F / M / ?</span>';
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php if ( count( $data ) ) : ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php if ( count( $data['wordcamps'] ) ) : ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> <h3 id="active-heading">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- Numbers for WordCamps occurring
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ Counts for WordCamps occurring
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php if ( $start_date->format( 'Y-m-d' ) === $end_date->format( 'Y-m-d' ) ) : ?>
</span><span class="cx" style="display: block; padding: 0 10px"> on <?php echo esc_html( $start_date->format( 'M jS, Y' ) ); ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php else : ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,7 +29,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <table class="striped widefat but-not-too-wide">
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>WordCamps</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number total"><?php echo number_format_i18n( count( $data ) ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number total"><?php echo number_format_i18n( count( $data['wordcamps'] ) ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> </table>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,33 +43,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Attendees</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['attendees'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $uniques['attendees'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['attendee'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['uniques']['attendee'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Organizers</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['organizers'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $uniques['organizers'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['organizer'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['uniques']['organizer'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Sessions</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['sessions'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['session'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td class="number">n/a</td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Speakers</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['speakers'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $uniques['speakers'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['speaker'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['uniques']['speaker'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Sponsors</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['sponsors'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $uniques['sponsors'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['sponsor'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['uniques']['sponsor'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> </table>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php if ( ! empty( $genders ) ) : ?>
- <h4>Gender Breakdown</h4>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php if ( ! empty( $data['genders'] ) ) : ?>
+ <h4>Estimated Gender Breakdown</h4>
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <table class="striped widefat but-not-too-wide">
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,24 +81,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Attendees</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['attendees'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['attendees']['female'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['attendees']['male'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['attendees']['unknown'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['attendee'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['attendee']['female'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['attendee']['male'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['attendee']['unknown'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Organizers</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['organizers'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['organizers']['female'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['organizers']['male'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['organizers']['unknown'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['organizer'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['organizer']['female'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['organizer']['male'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['organizer']['unknown'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Speakers</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td class="number"><?php echo number_format_i18n( $totals['speakers'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['speakers']['female'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['speakers']['male'] ); ?></td>
- <td class="number"><?php echo number_format_i18n( $genders['speakers']['unknown'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td class="number"><?php echo number_format_i18n( $data['totals']['speaker'] ); ?></td>
+ <td class="number"><?php echo number_format_i18n( $data['genders']['speaker']['female'] ); ?></td>
+ <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>
</ins><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> </table>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,46 +110,46 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <td>WordCamp</td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Date</td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td>Status</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td>Attendees<?php if ( ! empty( $genders ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
- <td>Organizers<?php if ( ! empty( $genders ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td>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>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td>Sessions</td>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td>Speakers<?php if ( ! empty( $genders ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td>Speakers<?php if ( ! empty( $data['genders'] ) ) : ?><br /><?php echo $gender_legend ?><?php endif; ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td>Sponsors</td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php foreach ( $data as $event ) : ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php foreach ( $data['wordcamps'] as $event ) : ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <td><a href="<?php echo esc_attr( $event['URL'] ); ?>"><?php echo esc_html( $event['Name'] ); ?></a></td>
- <td><?php echo esc_html( $event['Start Date (YYYY-mm-dd)'] ); ?></td>
- <td><?php echo esc_html( $event['Status'] ); ?></td>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <td><a href="<?php echo esc_attr( $event['info']['URL'] ); ?>"><?php echo esc_html( $event['info']['Name'] ); ?></a></td>
+ <td><?php echo esc_html( $event['info']['Start Date (YYYY-mm-dd)'] ); ?></td>
+ <td><?php echo esc_html( $event['info']['Status'] ); ?></td>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td class="number">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <span class="total"><?php echo number_format_i18n( $event['attendees']['total'] ); ?></span>
- <?php if ( ! empty( $genders ) ) : ?>
- / <?php echo number_format_i18n( $event['attendees']['gender']['female'] ); ?>
- / <?php echo number_format_i18n( $event['attendees']['gender']['male'] ); ?>
- / <?php echo number_format_i18n( $event['attendees']['gender']['unknown'] ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <span class="total"><?php echo number_format_i18n( $event['totals']['attendee'] ); ?></span>
+ <?php if ( ! empty( $data['genders'] ) ) : ?>
+ / <?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'] ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td class="number">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <span class="total"><?php echo number_format_i18n( $event['organizers']['total'] ); ?></span>
- <?php if ( ! empty( $genders ) ) : ?>
- / <?php echo number_format_i18n( $event['organizers']['gender']['female'] ); ?>
- / <?php echo number_format_i18n( $event['organizers']['gender']['male'] ); ?>
- / <?php echo number_format_i18n( $event['organizers']['gender']['unknown'] ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <span class="total"><?php echo number_format_i18n( $event['totals']['organizer'] ); ?></span>
+ <?php if ( ! empty( $data['genders'] ) ) : ?>
+ / <?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'] ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td class="number total">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo number_format_i18n( $event['sessions']['total'] ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php echo number_format_i18n( $event['totals']['session'] ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td class="number">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <span class="total"><?php echo number_format_i18n( $event['speakers']['total'] ); ?></span>
- <?php if ( ! empty( $genders ) ) : ?>
- / <?php echo number_format_i18n( $event['speakers']['gender']['female'] ); ?>
- / <?php echo number_format_i18n( $event['speakers']['gender']['male'] ); ?>
- / <?php echo number_format_i18n( $event['speakers']['gender']['unknown'] ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <span class="total"><?php echo number_format_i18n( $event['totals']['speaker'] ); ?></span>
+ <?php if ( ! empty( $data['genders'] ) ) : ?>
+ / <?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'] ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php endif; ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> <td class="number total">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <?php echo number_format_i18n( $event['sponsors']['total'] ); ?>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php echo number_format_i18n( $event['totals']['sponsor'] ); ?>
</ins><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php endforeach; ?>
</span></span></pre></div>
<a id="sitestrunkwordcamporgpublic_htmlwpcontentpluginswordcampreportsviewsreportwordcampcountsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php 2018-11-28 02:17:30 UTC (rev 7911)
+++ sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/views/report/wordcamp-counts.php 2018-11-28 22:47:15 UTC (rev 7912)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -55,7 +55,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> </td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <th scope="row"><label for="refresh">Include gender breakdowns</label></th>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <th scope="row"><label for="refresh">Include estimated gender breakdowns</label></th>
</ins><span class="cx" style="display: block; padding: 0 10px"> <td><input type="checkbox" id="include-gender" name="include-gender" <?php checked( $include_gender ); ?> /></td>
</span><span class="cx" style="display: block; padding: 0 10px"> </tr>
</span><span class="cx" style="display: block; padding: 0 10px"> <tr>
</span></span></pre>
</div>
</div>
</body>
</html>