Changeset 9711
- Timestamp:
- 04/09/2020 06:54:12 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/stats-overview.php
r9618 r9711 17 17 <?php foreach ( $projects as $slug => $project ) : 18 18 $name = str_replace( array( 'WordPress.org ', 'WordPress for ', 'WordPress ', 'ectory', ' - Development' ), '', $project->name ); 19 if ( $slug == 'wp-plugins' || $slug == 'wp-themes' ) { 20 $name = "Waiting $name"; 21 } 19 22 ?> 20 23 <th class="col-<?php echo esc_attr( sanitize_title( $name ) ); ?>"><?php echo esc_html( $name ); ?></th> … … 47 50 $percent = $translation_locale_statuses[ $locale_slug ][ $project->path ]; 48 51 49 if ( 'waiting' === $project->path ) { 52 if ( 'waiting' === $project->path || 'wp-plugins' === $project->path || 'wp-themes' === $project->path ) { 53 $project_link_title = ''; 54 if ( 'wp-plugins' === $project->path || 'wp-themes' === $project->path ) { 55 $project_link_title = "Last Updated {$project->cache_last_updated}"; 56 57 // Filter Plugins/Themes to Waiting (Most first) - Relying upon these being the last items. 58 $projecturl = add_query_arg( 'filter', 'strings-waiting-and-fuzzy', $projecturl ); 59 } 60 50 61 // Color code it on -0~500 waiting strings 51 62 $percent_class = 100-min( (int) ( $percent / 50 ) * 10, 100 ); … … 55 66 } 56 67 $percent_class = 'percent' . $percent_class; 57 echo '<td data-column-title="' . esc_attr( $project_name ) . '" data-sort-value="'. esc_attr( $percent ) . '" class="' . $percent_class .'"><a href="' . esc_url( $projecturl ) . '" >' . number_format( $percent ) . '</a></td>';68 echo '<td data-column-title="' . esc_attr( $project_name ) . '" data-sort-value="'. esc_attr( $percent ) . '" class="' . $percent_class .'"><a href="' . esc_url( $projecturl ) . '" title="' . esc_attr( $project_link_title ) . '">' . number_format( $percent ) . '</a></td>'; 58 69 } else { 59 70 $percent_class = 'percent' . (int) ( $percent / 10 ) * 10; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/class-plugin.php
r9616 r9711 47 47 48 48 add_action( 'init', [ $this, 'respect_robots_txt' ], 9 ); 49 50 add_action( 'init', [ $this, 'cron_tasks' ] ); 49 51 } 50 52 … … 58 60 // ?gp_route=robots.txt is here, as GlotPress ultimately is the router for the request. 59 61 add_rewrite_rule( '^robots\.txt$', 'index.php?robots=1&gp_route=robots.txt', 'top' ); 62 } 63 64 /** 65 * Some pages rely upon a regular cron task to update the stats rather than live updates. 66 */ 67 function cron_tasks() { 68 if ( ! wp_next_scheduled ( 'wporg_gp_stats_cache_waiting_strings' ) ) { 69 wp_schedule_event( time(), 'twicedaily', 'wporg_gp_stats_cache_waiting_strings' ); 70 } 71 add_action( 'wporg_gp_stats_cache_waiting_strings', [ __NAMESPACE__ . '\Routes\Stats', 'cache_waiting_strings' ] ); 60 72 } 61 73 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-stats.php
r9018 r9711 13 13 */ 14 14 class Stats extends GP_Route { 15 16 /** 17 * Cache some expensive queries to be run on a Cron task. 18 */ 19 public function cache_waiting_strings() { 20 global $wpdb; 21 22 $cached_projects = [ 23 GP::$project->by_path( 'wp-plugins' ), 24 GP::$project->by_path( 'wp-themes' ), 25 ]; 26 $sql = "SELECT 27 locale, locale_slug, 28 SUM( stats.waiting ) + SUM( stats.fuzzy ) as waiting_strings 29 FROM {$wpdb->project_translation_status} stats 30 LEFT JOIN {$wpdb->gp_projects} p ON stats.project_id = p.id 31 WHERE 32 p.parent_project_id = %d 33 AND p.active = 1 34 GROUP BY locale, locale_slug"; 35 36 foreach ( $cached_projects as $project ) { 37 $rows = $wpdb->get_results( $wpdb->prepare( $sql, $project->id ) ); 38 39 $cached_data = []; 40 foreach ( $rows as $set ) { 41 $locale_key = $set->locale; 42 if ( 'default' != $set->locale_slug ) { 43 $locale_key = $set->locale . '/' . $set->locale_slug; 44 } 45 46 $cached_data[ $locale_key ] = (int) $set->waiting_strings; 47 } 48 $cached_data[ 'last_updated' ] = time(); 49 50 update_option( __CLASS__ . '_cached_waiting_' . $project->slug, $cached_data, false ); 51 } 52 53 } 15 54 16 55 public function get_stats_overview() { … … 27 66 'apps/ios' => false, 28 67 'waiting' => false, 68 'wp-themes' => false, 69 'wp-plugins' => false, 29 70 ); 30 71 … … 84 125 85 126 // Append the Plugins/Themes waiting strings 86 /*$parent_project_ids = implode(',', array( 87 GP::$project->by_path( 'wp-plugins' )->id, 88 GP::$project->by_path( 'wp-themes' )->id, 89 ) ); 90 $sql = "SELECT 91 locale, locale_slug, 92 SUM( stats.waiting ) + SUM( stats.fuzzy ) as waiting_strings 93 FROM {$wpdb->project_translation_status} stats 94 LEFT JOIN {$wpdb->gp_projects} p ON stats.project_id = p.id 95 WHERE 96 p.parent_project_id IN ( $parent_project_ids ) 97 AND p.active = 1 98 GROUP BY locale, locale_slug"; 99 100 $rows = $wpdb->get_results( $sql ); 101 foreach ( $rows as $set ) { 102 $locale_key = $set->locale; 103 if ( 'default' != $set->locale_slug ) { 104 $locale_key = $set->locale . '/' . $set->locale_slug; 105 } 106 107 $translation_locale_statuses[ $locale_key ]['waiting'] += (int) $set->waiting_strings; 108 }*/ 127 foreach ( [ 'wp-plugins', 'wp-themes' ] as $project_slug ) { 128 $cached_data = get_option( __CLASS__ . '_cached_waiting_' . $project_slug, [] ); 129 $projects[ $project_slug ]->cache_last_updated = gmdate( 'Y-m-d H:i:s \U\T\C', $cached_data['last_updated'] ); 130 foreach ( $cached_data as $locale => $waiting ) { 131 $translation_locale_statuses[ $locale ][ $project_slug ] = $waiting; 132 } 133 } 109 134 110 135 // Calculate a list of [Locale] = % subtotals
Note: See TracChangeset
for help on using the changeset viewer.