Making WordPress.org


Ignore:
Timestamp:
12/18/2023 01:32:39 AM (10 months ago)
Author:
dd32
Message:

Plugin Directory: Stats: Display reviewer stats specifically of the plugins inbox (if possible).

Fixes #6994.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php

    r13033 r13063  
    9494        global $wpdb;
    9595
    96         $stats['as_of_date'] = gmdate( 'Y-m-d' );
    97 
    9896        $defaults = array(
    99             'date'       => $stats['as_of_date'],
     97            'date'       => gmdate( 'Y-m-d' ),
    10098            'num_days'   => 7,
    10199            'recentdays' => 7,
     
    235233        global $wpdb;
    236234
    237         $stats['as_of_date'] = gmdate( 'Y-m-d' );
    238 
    239235        $defaults = array(
    240             'date'       => $stats['as_of_date'],
     236            'date'       => gmdate( 'Y-m-d' ),
    241237            'num_days'   => 7,
    242238            'recentdays' => 7,
     
    248244
    249245        $stats = $args;
    250         $stats['data'] = [];
     246        $stats['start_date'] = gmdate( 'Y-m-d', time() - ( $args['num_days'] * DAY_IN_SECONDS ) );
     247        $stats['data']       = [];
    251248
    252249        $reviewers = get_users( [
     
    298295
    299296        // Fetch HelpScout stats from our stats. We might be able to pull some information from HS Stats instead.
     297        $stats_field_prefix = 'hs-plugins-';
     298        if (
     299            // See https://meta.trac.wordpress.org/changeset/13010
     300            strtotime( $stats['start_date'] ) < strtotime('2023-12-06')
     301        ) {
     302            $stats_field_prefix      = 'hs-';
     303            $stats['all-hs-warning'] = true;
     304        }
     305
    300306        $emails = $wpdb->get_results( $wpdb->prepare(
    301307            "SELECT `name`, `value`, SUM(views) AS count
    302308            FROM %i
    303             WHERE `name` IN( 'hs-total', 'hs-replies' )
     309            WHERE `name` IN( %s, %s )
    304310                AND `value` IN( {$reviewer_nicenames_list} )
    305                 AND `date` > DATE_SUB( %s, INTERVAL %d DAY )
     311                AND `date` > %s
    306312            GROUP BY `name`, `value`",
    307313            'stats_extras',
    308             $args['date'],
    309             $args['num_days']
     314            $stats_field_prefix . 'total',
     315            $stats_field_prefix . 'replies',
     316            $stats['start_date']
    310317        ) );
    311318
    312319        foreach ( $emails as $row ) {
    313320            $user  = get_user_by( 'slug', $row->value );
    314             $field = 'hs-total' === $row->name ? 'Email Actions' : 'Email Replies';
     321            $field = str_ends_with( $row->name, '-total' ) ? 'Email Actions' : 'Email Replies';
    315322            $stats['data'][ $user->ID ] ??= [];
    316323            $stats['data'][ $user->ID ][ $field ] = $row->count;
     
    725732            ?>
    726733            <ul style="font-style:italic;">
    727                 <li><code>^</code> : This is currently of all Helpscout mailboxes, not Plugins specific. Requires your Helpscout email to be the same as your WordPress.org email, or as one of your profiles alternate emails.</li>
     734                <?php if ( isset( $user_stats['all-hs-warning'] ) ) : ?>
     735                    <li><code>^</code> : This is of all Helpscout mailboxes, not Plugins specific, as plugins-only data is only available after <a href="https://meta.trac.wordpress.org/changeset/13010">2023-12-05</a>.</li>
     736                <?php endif; ?>
     737                <li><code>^</code> : Requires your Helpscout email to be the same as your WordPress.org email, or as one of your profiles alternate emails.</li>
    728738                <li><code>^</code> : Email "Actions" include sending emails, replying to emails, marking as spam, moving to different inbox, etc.</li>
    729739            </ul>
Note: See TracChangeset for help on using the changeset viewer.