Changeset 3968 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php
- Timestamp:
- 09/05/2016 07:59:47 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/sponsor-invoices-dashboard.php
r3807 r3968 249 249 250 250 $table_name = get_index_table_name(); 251 252 /* 253 * This query is limited at 100 rows to avoid requesting too much data from QBO. In most cases it shouldn't be 254 * a problem, but it's possible that at some point the number of pending invoices will exceed the limit, and 255 * we'll need to refactor this to update them in batches. 256 */ 251 $paid_invoices = array(); 252 257 253 $sent_invoices = $wpdb->get_results( " 258 254 SELECT blog_id, invoice_id, qbo_invoice_id 259 255 FROM $table_name 260 256 WHERE status = 'wcbsi_approved' 261 LIMIT 100 257 LIMIT 1000 262 258 " ); 263 259 264 $paid_invoices = \WordCamp_QBO_Client::get_paid_invoices( 265 wp_list_pluck( $sent_invoices, 'qbo_invoice_id' ) 266 ); 260 // Batch requests in order to avoid request size limits imposed by QuickBooks, nginx, etc 261 $qbo_invoice_ids = wp_list_pluck( $sent_invoices, 'qbo_invoice_id' ); 262 $qbo_invoice_ids = array_chunk( $qbo_invoice_ids, 20 ); 263 264 foreach( $qbo_invoice_ids as $batch ) { 265 $paid_invoices = array_merge( 266 $paid_invoices, 267 \WordCamp_QBO_Client::get_paid_invoices( $batch ) 268 ); 269 270 usleep( 300000 ); // Avoid hitting the API too frequently 271 } 267 272 268 273 mark_invoices_as_paid( $sent_invoices, $paid_invoices );
Note: See TracChangeset
for help on using the changeset viewer.