Changeset 6874 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php
- Timestamp:
- 03/14/2018 05:16:01 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/tools/class-stats-report.php
r6287 r6874 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Tools; 3 use WordPressdotorg\Plugin_Directory\Template; 3 4 4 5 /** … … 88 89 // Plugin Status Changes 89 90 // -------------- 90 $states = array( 'plugin_approve', 'plugin_delist', 'plugin_new', 'plugin_reject' ); 91 foreach ( $states as $state ) { 92 // The stats table used by bbPress1 (and could still be used, but isn't yet). 93 // Won't provide meaningful results for time intervals that include days after the switch to WP. 94 $stats[ $state ] = $wpdb->get_var( $wpdb->prepare( 95 "SELECT SUM(views) FROM stats_extras WHERE name = 'plugin' AND date < %s AND date > DATE_SUB( %s, INTERVAL %d DAY ) AND value = %s", 96 $args['date'], 97 $args['date'], 98 absint( $args['num_days'] ) + 1, 99 $state 100 ) ); 101 } 102 103 // Temporary until the above is updated to work with the new directory: 104 foreach ( array( 'plugin_approve', 'plugin_delist', 'plugin_reject' ) as $unused_stat ) { 105 if ( ! $stats[ $unused_stat ] ) { 106 $stats[ $unused_stat ] = __( 'N/A', 'wporg-plugins' ); 107 } 108 } 91 $stats[ 'plugin_approve' ] = (int) $wpdb->get_var( $wpdb->prepare( 92 "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = '_approved' AND meta_value >= %d AND meta_value < %d", 93 strtotime( $args['date'] ) - ( $args['num_days'] * DAY_IN_SECONDS ), 94 strtotime( $args['date'] ) + DAY_IN_SECONDS 95 ) ); 96 97 $stats[ 'plugin_delist' ] = (int) $wpdb->get_var( $wpdb->prepare( 98 "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'plugin_closed_date' AND meta_value >= %s AND meta_value < %s", 99 date( 'Y-m-d', strtotime( $args['date'] ) - ( $args['num_days'] * DAY_IN_SECONDS ) ), 100 date( 'Y-m-d', strtotime( $args['date'] ) ) 101 ) ); 102 103 $stats[ 'plugin_delist_reasons' ] = array_column( $wpdb->get_results( $wpdb->prepare( 104 "SELECT reason.meta_value as reason, COUNT(*) as count FROM $wpdb->postmeta closed_date JOIN $wpdb->postmeta reason ON closed_date.post_id = reason.post_id AND reason.meta_key = '_close_reason' WHERE closed_date.meta_key = 'plugin_closed_date' AND closed_date.meta_value >= %s AND closed_date.meta_value < %s GROUP BY reason.meta_value", 105 date( 'Y-m-d', strtotime( $args['date'] ) - ( $args['num_days'] * DAY_IN_SECONDS ) ), 106 date( 'Y-m-d', strtotime( $args['date'] ) ) 107 ) ), 'count', 'reason' ); 108 109 $stats[ 'plugin_new' ] = (int) $wpdb->get_var( $wpdb->prepare( 110 "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'plugin' AND post_date >= %s AND post_date < %s", 111 date( 'Y-m-d', strtotime( $args['date'] ) - ( $args['num_days'] * DAY_IN_SECONDS ) ), 112 date( 'Y-m-d', strtotime( $args['date'] ) ) 113 ) ); 114 115 $stats[ 'plugin_reject' ] = (int) $wpdb->get_var( $wpdb->prepare( 116 "SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = '_rejected' AND meta_value >= %d AND meta_value < %d", 117 strtotime( $args['date'] ) - ( $args['num_days'] * DAY_IN_SECONDS ), 118 strtotime( $args['date'] ) + DAY_IN_SECONDS 119 ) ); 109 120 110 121 // -------------- … … 294 305 $stats['plugin_delist'] 295 306 ); 307 $reasons = array(); 308 if ( $stats['plugin_delist_reasons'] ) { 309 echo '<ul>'; 310 foreach ( $stats['plugin_delist_reasons'] as $reason => $number ) { 311 $reason = Template::get_close_reasons()[ $reason ]; 312 echo "<li> {$reason}: {$number}</li>"; 313 } 314 echo '</ul>'; 315 } 296 316 ?> 297 317 </li>
Note: See TracChangeset
for help on using the changeset viewer.