Changeset 4728
- Timestamp:
- 01/19/2017 06:48:03 AM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/jobs/class-meta-sync.php
r4423 r4728 34 34 35 35 $download_count_table = PLUGINS_TABLE_PREFIX . 'download_counts'; 36 $bbpress_topic_slug_table = PLUGINS_TABLE_PREFIX . 'topics';37 36 38 37 $changed_download_counts = $wpdb->get_results( 39 38 "SELECT p.id as post_id, downloads 40 39 FROM `{$wpdb->posts}` p 41 JOIN `{$bbpress_topic_slug_table}` t ON p.post_name = t.topic_slug 42 JOIN `{$download_count_table}` c on t.topic_id = c.topic_id 40 JOIN `{$download_count_table}` c on p.post_name = c.plugin_slug 43 41 LEFT JOIN `{$wpdb->postmeta}` pm ON p.id = pm.post_id AND pm.meta_key = 'downloads' 44 42 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/zip/class-serve.php
r3081 r4728 179 179 global $wpdb; 180 180 181 $stats = array( 181 $stats_dedup_log_table = PLUGINS_TABLE_PREFIX . 'downloads'; 182 $stats_download_table = PLUGINS_TABLE_PREFIX . 'download_counts'; 183 $stats_download_daily_table = PLUGINS_TABLE_PREFIX . 'stats'; 184 185 // Very basic de-duplication for downloads. 186 $recent = $wpdb->get_var( $wpdb->prepare( 187 "SELECT `client_ip` 188 FROM {$stats_dedup_log_table} 189 WHERE 190 plugin_slug = %s AND 191 client_ip = %s AND 192 user_agent = %s AND 193 stamp BETWEEN %s AND %s 194 LIMIT 1", 195 $request['slug'], 196 $_SERVER['REMOTE_ADDR'], 197 $_SERVER['HTTP_USER_AGENT'], 198 gmdate( 'Y-m-d 00:00:00' ), 199 gmdate( 'Y-m-d 23:59:59' ) 200 ) ); 201 202 if ( $recent ) { 203 return; 204 } 205 206 $wpdb->query( $wpdb->prepare( 207 "INSERT INTO {$stats_download_table} (`plugin_slug`, `downloads`) VALUES ( %s, 1 ) ON DUPLICATE KEY UPDATE `downloads` = `downloads` + 1", 208 $stats['plugin_slug'] 209 ) ); 210 211 $wpdb->query( $wpdb->prepare( 212 "INSERT INTO {$stats_download_daily_table} (`plugin_slug`, `stamp`, `downloads`) VALUES ( %s, %s, 1 ) ON DUPLICATE KEY UPDATE `downloads` = `downloads` + 1", 213 $stats['plugin_slug'], 214 gmdate( 'Y-m-d' ) 215 ) ); 216 217 $wpdb->insert( $stats_dedup_log_table, array( 182 218 'plugin_slug' => $request['slug'], 183 219 'client_ip' => $_SERVER['REMOTE_ADDR'], 184 'client_host' => gethostbyaddr( $_SERVER['REMOTE_ADDR'] ), 185 'user_agent' => $_SERVER['HTTP_USER_AGENT'] 186 ); 187 // $wpdb->insert( stats_table, $stats ); 188 // TODO: This is stored in bbPress tables still. 189 // $post_id = $this->get_post_id( $request['slug'] ); 190 // $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = meta_value + 1 WHERE post_id = %d AND meta_key = 'downloads'", $post_id ) ); 220 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 221 'stamp' => gmdate( 'Y-m-d H:i:s' ) 222 ) ); 223 191 224 } 192 225
Note: See TracChangeset
for help on using the changeset viewer.