Making WordPress.org

Changeset 12992


Ignore:
Timestamp:
12/01/2023 05:05:31 AM (2 years ago)
Author:
dd32
Message:

Plugin Directory: Stats: Break out 'pending' plugin counts into whether the plugin is waiting on the Author or a Reviewer.

File:
1 edited

Legend:

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

    r12523 r12992  
    7070     *     Array of stats.
    7171     *
    72      *     @type int $plugin_approve                        The number of plugins approved within the defined time interval.
    73      *     @type int $plugin_delist                         The number of plugins delisted within the defined time interval.
    74      *     @type int $plugin_new                            The number of plugins submitted within the defined time interval.
    75      *     @type int $plugin_reject                         The number of plugins rejected within the defined time interval.
    76      *     @type int $in_queue                              The number of plugins currently in the queue (new or pending).
    77      *     @type int $in_queue_new                          The number of new plugins currently in the queue.
    78      *     @type int $in_queue_pending                      The number of pending plugins currently in the queue.
    79      *     @type int $in_queue_from_time_window             The number of plugins currently in the queue submitted during the specified time window.
    80      *     @type int $in_queue_old                          The number of plugins currently in the queue that are older than "recently".
    81      *     @type int $helpscout_queue_total_conversations   The number of ongoing Help Scout conversations.
    82      *     @type int $helpscout_queue_new_conversations     The number of new Help Scout conversations.
    83      *     @type int $helpscout_queue_customers             The number of unique Plugin authors contacted.
    84      *     @type int $helpscout_queue_conversations_per_day The number of Help Scout conversations per day.
    85      *     @type int $helpscout_queue_busiest_day           The busiest day in the Help Scout queue.
    86      *     @type int $helpscout_queue_messages_received     The number of emails received in HelpScout.
    87      *     @type int $helpscout_queue_replies_sent          The number of replies sent to emails.
    88      *     @type int $helpscout_queue_emails_created        The number of new outgoing conversations created.
     72     *     @type int   $plugin_approve                        The number of plugins approved within the defined time interval.
     73     *     @type int   $plugin_delist                         The number of plugins delisted within the defined time interval.
     74     *     @type array $plugin_delist_reasons                 The number of plugins delisted within the defined time interval, broken down by reason.
     75     *     @type int   $plugin_new                            The number of plugins submitted within the defined time interval.
     76     *     @type int   $plugin_reject                         The number of plugins rejected within the defined time interval.
     77     *     @type int   $in_queue                              The number of plugins currently in the queue (new or pending).
     78     *     @type int   $in_queue_new                          The number of new plugins currently in the queue.
     79     *     @type int   $in_queue_pending                      The number of pending plugins currently in the queue.
     80     *     @type array $in_queue_pending_why                  The number of pending plugins currently in the queue, broken down by whom we're waiting on.
     81     *     @type int   $in_queue_from_time_window             The number of plugins currently in the queue submitted during the specified time window.
     82     *     @type int   $in_queue_old                          The number of plugins currently in the queue that are older than "recently".
     83     *     @type int   $helpscout_queue_total_conversations   The number of ongoing Help Scout conversations.
     84     *     @type int   $helpscout_queue_new_conversations     The number of new Help Scout conversations.
     85     *     @type int   $helpscout_queue_customers             The number of unique Plugin authors contacted.
     86     *     @type int   $helpscout_queue_conversations_per_day The number of Help Scout conversations per day.
     87     *     @type int   $helpscout_queue_busiest_day           The busiest day in the Help Scout queue.
     88     *     @type int   $helpscout_queue_messages_received     The number of emails received in HelpScout.
     89     *     @type int   $helpscout_queue_replies_sent          The number of replies sent to emails.
     90     *     @type int   $helpscout_queue_emails_created        The number of new outgoing conversations created.
    8991     * }
    9092     */
     
    127129        ) ), 'count', 'reason' );
    128130
     131        $stats[ 'plugin_delist_reasons' ] = array_map( 'intval', $stats[ 'plugin_delist_reasons' ] );
     132
    129133        $stats[ 'plugin_new' ] = (int) $wpdb->get_var( $wpdb->prepare(
    130134            "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = '_submitted_date' AND meta_value >= %d AND meta_value < %d",
     
    143147        // --------------
    144148        // # of plugins currently in the queue that are new (have not been processed/replied to yet)
    145         $stats['in_queue_new'] = $wpdb->get_var(
     149        $stats['in_queue_new'] = (int) $wpdb->get_var(
    146150            "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` = 'new'"
    147151        );
    148152
    149153        // # of plugins currently in the queue that are pending (have been initially replied to)
    150         $stats['in_queue_pending'] = $wpdb->get_var(
     154        $stats['in_queue_pending'] = (int) $wpdb->get_var(
    151155            "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` = 'pending'"
    152156        );
    153157
     158        // # Break down the plugins in the queue, based on if we're still waiting on a reply.
     159        $stats['in_queue_pending_why'] = $wpdb->get_row( $wpdb->prepare(
     160            'SELECT
     161                SUM( IF( active = 0, 1, 0 ) ) AS `author`,
     162                SUM( IF( active > 0, 1, 0 ) ) AS `reviewer`
     163            FROM (
     164                SELECT
     165                    p.post_name,
     166                    SUM( IF( emails.status = "closed", 1, 0 ) ) AS `closed`,
     167                    SUM( IF( emails.status = "active", 1, 0 ) ) AS `active`
     168                FROM %i p
     169                    LEFT JOIN %i meta ON meta.meta_key = "plugins" AND meta.meta_value = p.post_name
     170                    LEFT JOIN %i emails ON meta.helpscout_id = emails.id
     171                WHERE p.post_status = "pending"
     172                GROUP BY p.ID
     173            ) subquery',
     174            $wpdb->posts,
     175            "{$wpdb->base_prefix}helpscout_meta",
     176            "{$wpdb->base_prefix}helpscout",
     177        ), ARRAY_A );
     178
     179        $stats['in_queue_pending_why'] = array_map( 'intval', $stats['in_queue_pending_why'] );
     180
    154181        // # of plugins currently in the queue (new + pending)
    155182        $stats['in_queue'] = $stats['in_queue_new'] + $stats['in_queue_pending'];
    156183
    157184        // # of plugins currently in the queue submitted during the specified time window
    158         $stats['in_queue_from_time_window'] = $wpdb->get_var( $wpdb->prepare(
     185        $stats['in_queue_from_time_window'] = (int) $wpdb->get_var( $wpdb->prepare(
    159186            "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'new','pending' ) AND post_date < %s AND post_date > DATE_SUB( %s, INTERVAL %d DAY )",
    160187            $args['date'],
     
    164191
    165192        // # of plugins currently in the queue that are older than "recently"
    166         $stats['in_queue_old'] = $wpdb->get_var( $wpdb->prepare(
     193        $stats['in_queue_old'] = (int) $wpdb->get_var( $wpdb->prepare(
    167194            "SELECT COUNT(*) FROM $wpdb->posts WHERE `post_type` = 'plugin' AND `post_status` IN ( 'new','pending' ) AND post_date < DATE_SUB( %s, INTERVAL %d DAY )",
    168195            $args['date'],
     
    396423            ?>
    397424            </li>
     425            <li>
     426            <?php
     427                /* translators: %d: number of pending plugins */
     428                printf(
     429                    __( '&rarr; (pending; waiting on author)* : %d', 'wporg-plugins' ),
     430                    esc_html( $stats['in_queue_pending_why']['author'] )
     431                );
     432            ?>
     433            </li>
     434            <li>
     435            <?php
     436                /* translators: %d: number of pending plugins */
     437                printf(
     438                    __( '&rarr; (pending; waiting on reviewer)* : %d', 'wporg-plugins' ),
     439                    esc_html( $stats['in_queue_pending_why']['reviewer'] )
     440                );
     441            ?>
     442            </li>
    398443        </ul>
    399444
Note: See TracChangeset for help on using the changeset viewer.