Changeset 2114
- Timestamp:
- 11/22/2015 10:30:57 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-stats
- Files:
-
- 3 added
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-stats/stats/project.php
r2102 r2114 13 13 * @author dd32 14 14 */ 15 class GP_WPorg_Project_Stats extends GP_Plugin { 16 var $id = 'wporg-project-stats'; 15 class WPorg_GP_Project_Stats { 17 16 18 17 public $projects_to_update = array(); 19 18 20 19 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 ); 26 25 27 26 // 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' ) ); 29 28 30 $ gpdb->project_translation_status = $gpdb->prefix . 'project_translation_status';29 $wpdb->project_translation_status = $gp_table_prefix . 'project_translation_status'; 31 30 } 32 31 … … 79 78 80 79 function shutdown() { 81 global $ gpdb;80 global $wpdb; 82 81 $values = array(); 83 82 … … 119 118 $counts = $this->get_project_translation_counts( $project_id, $locale, $locale_slug ); 120 119 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)', 122 121 $project_id, 123 122 $locale, … … 134 133 // If we're processing a large batch, add them as we go to avoid query lengths & memory limits 135 134 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`)" ); 137 136 $values = array(); 138 137 } … … 141 140 142 141 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`)" ); 144 143 } 145 144 } 146 145 147 146 } 148 GP::$plugins->wporg_project_stats = new GP_WPorg_Project_Stats;149 147 150 148 /* -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-custom-stats/stats/user.php
r2102 r2114 8 8 * @author dd32 9 9 */ 10 class GP_WPorg_User_Stats extends GP_Plugin { 11 var $id = 'wporg-user-stats'; 10 class WPorg_GP_User_Stats { 12 11 13 12 function __construct() { 14 global $ gpdb;13 global $wpdb, $gp_table_prefix; 15 14 16 parent::__construct(); 17 $this->add_action( 'translation_created' ); 18 $this->add_action( 'translation_saved' ); 15 add_action( 'translation_created', array( $this, 'translation_created' ) ); 16 add_action( 'translation_saved', array( $this, 'translation_saved' ) ); 19 17 20 $ gpdb->user_translations_count = $gpdb->prefix . 'user_translations_count';18 $wpdb->user_translations_count = $gp_table_prefix . 'user_translations_count'; 21 19 } 22 20 … … 45 43 46 44 } 47 48 45 } 49 46 50 47 function bump_user_stat( $user_id, $locale, $locale_slug, $suggested = 0, $accepted = 0 ) { 51 global $ gpdb;52 $ gpdb->query( $gpdb->prepare(53 "INSERT INTO {$ gpdb->user_translations_count} (`user_id`, `locale`, `locale_slug`, `suggested`, `accepted`) VALUES (%d, %s, %s, %d, %d)48 global $wpdb; 49 $wpdb->query( $wpdb->prepare( 50 "INSERT INTO {$wpdb->user_translations_count} (`user_id`, `locale`, `locale_slug`, `suggested`, `accepted`) VALUES (%d, %s, %s, %d, %d) 54 51 ON DUPLICATE KEY UPDATE `suggested`=`suggested` + VALUES(`suggested`), `accepted`=`accepted` + VALUES(`accepted`)", 55 52 $user_id, $locale, $locale_slug, $suggested, $accepted … … 58 55 59 56 } 60 GP::$plugins->wporg_user_stats = new GP_WPorg_User_Stats;61 57 62 58 /*
Note: See TracChangeset
for help on using the changeset viewer.