Making WordPress.org


Ignore:
Timestamp:
03/24/2019 05:14:26 PM (6 years ago)
Author:
ocean90
Message:

Translate: Extend contributors table for locale projects with a toggle to view per-project stats.

Fixes #3613.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/locale-project.php

    r7480 r8497  
    207207        <table class="locale-project-contributors-table">
    208208            <thead>
    209                 <th class="contributor-name">Contributor</th>
    210                 <th class="contributor-stats">Translations*</th>
     209                <tr>
     210                    <th class="contributor-name">Contributor</th>
     211                    <th class="contributor-stats">Translations</th>
     212                </tr>
    211213            </thead>
    212214            <tbody>
    213215            <?php
    214216            foreach ( $locale_contributors['contributors'] as $contributor ) {
     217                $detailed = '';
     218
     219                if ( 'wp-plugins' === $project->path ) {
     220                    // Ensure consistent order of development and stable projects.
     221                    usort( $contributor->detailed, function( $a, $b ) {
     222                        return strnatcasecmp( $a->project->name, $b->project->name );
     223                    } );
     224                }
     225
     226                foreach ( $contributor->detailed as $detail_project_id => $detail_data ) {
     227                    $detailed .= '<strong class="detailed__project-name">' . $detail_data->project->name . ':</strong>';
     228
     229                    if ( $detail_data->total_count > 0 ) {
     230                        $total_count = gp_link_get(
     231                            gp_url_project(
     232                                $detail_data->project->path,
     233                                gp_url_join( $locale->slug, $set_slug ),
     234                                [
     235                                    'filters[translated]' => 'yes',
     236                                    'filters[status]'     => 'current_or_waiting_or_fuzzy_or_untranslated',
     237                                    'filters[user_login]' => $contributor->login,
     238                                ]
     239                            ),
     240                            number_format_i18n( $detail_data->total_count )
     241                        );
     242                    } else {
     243                        $total_count = number_format_i18n( $detail_data->total_count );
     244                    }
     245
     246                    if ( $detail_data->current_count > 0 ) {
     247                        $current_count = gp_link_get(
     248                            gp_url_project(
     249                                $detail_data->project->path,
     250                                gp_url_join( $locale->slug, $set_slug ),
     251                                [
     252                                    'filters[translated]' => 'yes',
     253                                    'filters[status]'     => 'current',
     254                                    'filters[user_login]' => $contributor->login,
     255                                ]
     256                            ),
     257                            number_format_i18n( $detail_data->current_count )
     258                        );
     259                    } else {
     260                        $current_count = number_format_i18n( $detail_data->current_count );
     261                    }
     262
     263                    if ( $detail_data->waiting_count > 0 ) {
     264                        $waiting_count = gp_link_get(
     265                            gp_url_project(
     266                                $detail_data->project->path,
     267                                gp_url_join( $locale->slug, $set_slug ),
     268                                [
     269                                    'filters[translated]' => 'yes',
     270                                    'filters[status]'     => 'waiting',
     271                                    'filters[user_login]' => $contributor->login,
     272                                ]
     273                            ),
     274                            number_format_i18n( $detail_data->waiting_count )
     275                        );
     276                    } else {
     277                        $waiting_count = number_format_i18n( $detail_data->waiting_count );
     278                    }
     279
     280                    if ( $detail_data->fuzzy_count > 0 ) {
     281                        $fuzzy_count = gp_link_get(
     282                            gp_url_project(
     283                                $detail_data->project->path,
     284                                gp_url_join( $locale->slug, $set_slug ),
     285                                [
     286                                    'filters[translated]' => 'yes',
     287                                    'filters[status]'     => 'fuzzy',
     288                                    'filters[user_login]' => $contributor->login,
     289                                ]
     290                            ),
     291                            number_format_i18n( $detail_data->fuzzy_count )
     292                        );
     293                    } else {
     294                        $fuzzy_count = number_format_i18n( $detail_data->fuzzy_count );
     295                    }
     296
     297                    $detailed .= sprintf(
     298                        '
     299                            <div class="total">
     300                                <p>%s</p>
     301                            </div>
     302                            <div class="current">
     303                                <p>%s</p>
     304                            </div>
     305                            <div class="waiting">
     306                                <p>%s</p>
     307                            </div>
     308                            <div class="fuzzy">
     309                                <p>%s</p>
     310                            </div>
     311                        ',
     312                        $total_count,
     313                        $current_count,
     314                        $waiting_count,
     315                        $fuzzy_count
     316                    );
     317                }
     318
    215319                printf(
    216320                    '<tr>
     
    218322                            %s
    219323                            <a href="https://profiles.wordpress.org/%s/">%s %s</a>
    220                             <span>Last Activity: %s ago</span>
     324                            <span>Last translation submitted: %s ago</span>
    221325                        </td>
    222326                        <td class="contributor-stats">
     
    237341                                <p>%s</p>
    238342                            </div>
    239                         <td>
     343                            <div class="detailed">
     344                                <details>
     345                                    <summary>Per project</summary>
     346                                    %s
     347                                </details>
     348                            </div>
     349                        </td>
    240350                    </tr>',
    241351                    $contributor->is_editor ? '<span class="translation-editor">Editor</span>' : '',
    242352                    $contributor->nicename,
    243353                    get_avatar( $contributor->email, 40 ),
    244                     $contributor->display_name ? $contributor->display_name : $contributor->nicename,
     354                    $contributor->display_name ?: $contributor->nicename,
    245355                    human_time_diff( strtotime( $contributor->last_update ) ),
    246356                    number_format_i18n( $contributor->total_count ),
    247357                    number_format_i18n( $contributor->current_count ),
    248358                    number_format_i18n( $contributor->waiting_count ),
    249                     number_format_i18n( $contributor->fuzzy_count )
     359                    number_format_i18n( $contributor->fuzzy_count ),
     360                    $detailed
    250361                );
    251362            }
     
    253364            </tbody>
    254365        </table>
    255         <p class="stats-hint">* Data for the last 365 days.</p>
    256366        <?php else : ?>
    257367            <p>None, be the first?</p>
     
    272382                        $editor->nicename,
    273383                        get_avatar( $editor->email, 40 ),
    274                         $editor->display_name ? $editor->display_name : $editor->nicename
     384                        $editor->display_name ?: $editor->nicename
    275385                    );
    276386                }
Note: See TracChangeset for help on using the changeset viewer.