Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Rarst
Last active July 28, 2019 17:31
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Rarst/826b4f40c7a715582504 to your computer and use it in GitHub Desktop.
Save Rarst/826b4f40c7a715582504 to your computer and use it in GitHub Desktop.
WordPress core contributors by version. Input data from https://api.wordpress.org/core/credits/1.1/?version=x.x
<?php
$data_dir = 'c:/server/www/dev/data/';
$releases = [ ];
foreach ( range( 3.2, 4.0, 0.1 ) as $version ) {
$version = number_format( $version, 1 );
$data = json_decode( file_get_contents( $data_dir . $version . '.json' ), true );
$groups = wp_list_pluck( $data['groups'], 'data' );
unset( $groups['libraries'] );
$groups = array_map( 'array_keys', $groups );
$releases[ $version ] = call_user_func_array( 'array_merge', $groups );
$releases[ $version ] = array_map( 'strtolower', $releases[ $version ] );
$releases[ $version ] = array_unique( $releases[ $version ] );
}
$all_contributors = $releases['3.2'];
unset( $releases['3.2'] );
$total_counts = [ ];
$repeat_counts = [ ];
$new_counts = [ ];
foreach ( $releases as $version => $contributors ) {
$new_contributors = array_filter( $contributors, function ( $contributor ) use ( $all_contributors ) {
return ! in_array( strtolower( $contributor ), $all_contributors );
} );
$all_contributors = array_unique( array_merge( $all_contributors, $contributors ) );
$new_count = count( $new_contributors );
$total_count = count( $contributors );
$total_counts[] = $total_count;
$repeat_counts[] = $total_count - $new_count;
$new_counts[] = $new_count;
}
?>
<style type="text/css">
#legend .bar-legend li {
display: inline;
list-style-type: none;
text-align: center;
margin-left: 10px;
}
#legend .bar-legend span {
display: inline-block;
width: 16px;
height: 16px;
vertical-align: middle;
margin: 0 5px;
}
</style>
<div id="legend"></div>
<canvas id="myChart" width="800" height="400"></canvas>
<script type="text/javascript" src="//cdn.jsdelivr.net/chart.js/1.0.1-beta.4/Chart.min.js"></script>
<script type="text/javascript">
var ctx = document.getElementById("myChart").getContext("2d");
var data = {
labels : <?= json_encode(array_keys($releases)) ?>,
datasets: [
{
label : "Total contributors",
fillColor: "rgba(220,220,220,0.5)",
data : <?= json_encode($total_counts) ?>
},
{
label : "Repeat contributors",
fillColor: "rgba(0, 168, 240,0.5)",
data : <?= json_encode($repeat_counts) ?>
},
{
label : "New contributors",
fillColor: "rgba( 192, 216, 0,0.5)",
data : <?= json_encode($new_counts) ?>
}
]
};
var myBarChart = new Chart(ctx).Bar(data);
var legendHolder = document.getElementById('legend');
legendHolder.innerHTML = myBarChart.generateLegend();
</script>
<?php
@swissspidy
Copy link

Here's the current data including 4.4: https://cloudup.com/coyGiBFdwUf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment