Making WordPress.org


Ignore:
Timestamp:
11/22/2015 10:30:57 PM (11 years ago)
Author:
ocean90
Message:

Translate: Convert and merge the GP plugins "wporg-user-stats" and "wporg-project-stats" to a WP plugin.

See #1352.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-stats
Files:
2 added
1 copied

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-stats/stats/project.php

    r2102 r2114  
    1313 * @author dd32
    1414 */
    15 class GP_WPorg_Project_Stats extends GP_Plugin {
    16         var $id = 'wporg-project-stats';
     15class WPorg_GP_Project_Stats {
    1716
    1817        public $projects_to_update = array();
    1918
    2019        function __construct() {
    21                 global $gpdb;
    22                 parent::__construct();
    23                 $this->add_action( 'translation_created' );
    24                 $this->add_action( 'translation_saved' );
    25                 $this->add_action( 'originals_imported', array( 'args' => 5 ) );
     20                global $wpdb, $gp_table_prefix;
     21
     22                add_action( 'translation_created', array( $this, 'translation_created' ) );
     23                add_action( 'translation_saved', array( $this, 'translation_saved' ) );
     24                add_action( 'originals_imported', array( $this, 'originals_imported' ), 10, 5 );
    2625
    2726                // DB Writes are delayed until shutdown to bulk-update the stats during imports
    28                 $this->add_action( 'shutdown' );
     27                add_action( 'shutdown', array( $this, 'shutdown' ) );
    2928
    30                 $gpdb->project_translation_status = $gpdb->prefix . 'project_translation_status';
     29                $wpdb->project_translation_status = $gp_table_prefix . 'project_translation_status';
    3130        }
    3231
     
    7978
    8079        function shutdown() {
    81                 global $gpdb;
     80                global $wpdb;
    8281                $values = array();
    8382
     
    119118                                $counts = $this->get_project_translation_counts( $project_id, $locale, $locale_slug );
    120119
    121                                 $values[] = $gpdb->prepare( '(%d, %s, %s, %d, %d, %d, %d, %d, %d)',
     120                                $values[] = $wpdb->prepare( '(%d, %s, %s, %d, %d, %d, %d, %d, %d)',
    122121                                        $project_id,
    123122                                        $locale,
     
    134133                        // If we're processing a large batch, add them as we go to avoid query lengths & memory limits
    135134                        if ( count( $values ) > 50 ) {
    136                                 $gpdb->query( "INSERT INTO {$gpdb->project_translation_status} (`project_id`, `locale`, `locale_slug`, `all`, `current`, `waiting`, `fuzzy`, `warnings`, `untranslated` ) VALUES " . implode( ', ', $values ) . " ON DUPLICATE KEY UPDATE `all`=VALUES(`all`), `current`=VALUES(`current`), `waiting`=VAlUES(`waiting`), `fuzzy`=VALUES(`fuzzy`), `warnings`=VALUES(`warnings`), `untranslated`=VALUES(`untranslated`)" );
     135                                $wpdb->query( "INSERT INTO {$wpdb->project_translation_status} (`project_id`, `locale`, `locale_slug`, `all`, `current`, `waiting`, `fuzzy`, `warnings`, `untranslated` ) VALUES " . implode( ', ', $values ) . " ON DUPLICATE KEY UPDATE `all`=VALUES(`all`), `current`=VALUES(`current`), `waiting`=VAlUES(`waiting`), `fuzzy`=VALUES(`fuzzy`), `warnings`=VALUES(`warnings`), `untranslated`=VALUES(`untranslated`)" );
    137136                                $values = array();
    138137                        }
     
    141140
    142141                if ( $values ) {
    143                         $gpdb->query( "INSERT INTO {$gpdb->project_translation_status} (`project_id`, `locale`, `locale_slug`, `all`, `current`, `waiting`, `fuzzy`, `warnings`, `untranslated` ) VALUES " . implode( ', ', $values ) . " ON DUPLICATE KEY UPDATE `all`=VALUES(`all`), `current`=VALUES(`current`), `waiting`=VALUES(`waiting`), `fuzzy`=VALUES(`fuzzy`), `warnings`=VALUES(`warnings`), `untranslated`=VALUES(`untranslated`)" );
     142                        $wpdb->query( "INSERT INTO {$wpdb->project_translation_status} (`project_id`, `locale`, `locale_slug`, `all`, `current`, `waiting`, `fuzzy`, `warnings`, `untranslated` ) VALUES " . implode( ', ', $values ) . " ON DUPLICATE KEY UPDATE `all`=VALUES(`all`), `current`=VALUES(`current`), `waiting`=VALUES(`waiting`), `fuzzy`=VALUES(`fuzzy`), `warnings`=VALUES(`warnings`), `untranslated`=VALUES(`untranslated`)" );
    144143                }
    145144        }
    146145
    147146}
    148 GP::$plugins->wporg_project_stats = new GP_WPorg_Project_Stats;
    149147
    150148/*
Note: See TracChangeset for help on using the changeset viewer.