This commit is contained in:
Paul Kevan 2024-07-03 12:02:08 +01:00
parent a26287cd68
commit 49fe6d8e95
2 changed files with 10 additions and 7 deletions

View file

@ -186,7 +186,7 @@ function render_contributor_report_page() {
}
$all_contributor_data = XProfile\get_all_xprofile_contributors_indexed();
?>
?>
<p>
<b>Total:</b><?php echo count( $contributors ); ?>
<b>Status:</b>
@ -214,13 +214,16 @@ function render_contributor_report_page() {
<th>Last login</th>
<th>Status</th>
</tr>
<?php
<?php
$export_data = array();
foreach ( $contributors as $c ) {
$pledge_company = get_post( $c->post_parent );
$pledge_company_title = get_the_title( $pledge_company ) ?? 'unattached';
$user_id = get_post_meta( $c->ID, 'wporg_user_id', true );
$xprofile = $all_contributor_data[ $user_id ] ?? [ 'team_names' => [], 'hours_per_week' => 0 ];
$xprofile = $all_contributor_data[ $user_id ] ?? [
'team_names' => [],
'hours_per_week' => 0
];
$xprofile_teams = $xprofile['team_names'] ?? [];
$user = get_user_by( 'ID', $user_id );
$last_login = get_user_meta( $user_id, 'last_logged_in', true );
@ -241,7 +244,6 @@ function render_contributor_report_page() {
echo '</table>';
set_transient( 'wporg_5ftf_contributor_report_' . $status, $export_data, 2 * MINUTE_IN_SECONDS );
}
/**
* CSV export runner, grabs data lazily from a transient.
@ -271,7 +273,6 @@ function export_csv() {
/**
* Export contributors as a CSV, also from transient.
*
*/
function export_contributors_csv() {

View file

@ -76,12 +76,14 @@ function get_all_xprofile_contributor_hours_teams(): array {
* @return array
*/
function get_all_xprofile_contributors_indexed() : array {
$all_data = get_all_xprofile_contributor_hours_teams();
$newdata = array();
foreach ( $all_data as $contributor ) {
$newdata[ $contributor->user_id ] = [ 'hours_per_week' => $contributor->hours_per_week, 'team_names' => $contributor->team_names ];
$newdata[ $contributor->user_id ] = [
'hours_per_week' => $contributor->hours_per_week,
'team_names' => $contributor->team_names,
];
}
return $newdata;