| @@ 54-66 (lines=13) @@ | ||
| 51 | return $this->enqueue_all_ids_as_action( 'jetpack_full_sync_comments', $wpdb->comments, 'comment_ID', $this->get_where_sql( $config ) ); |
|
| 52 | } |
|
| 53 | ||
| 54 | public function estimate_full_sync_actions( $config ) { |
|
| 55 | global $wpdb; |
|
| 56 | ||
| 57 | $query = "SELECT count(*) FROM $wpdb->comments"; |
|
| 58 | ||
| 59 | if ( $where_sql = $this->get_where_sql( $config ) ) { |
|
| 60 | $query .= ' WHERE ' . $where_sql; |
|
| 61 | } |
|
| 62 | ||
| 63 | $count = $wpdb->get_var( $query ); |
|
| 64 | ||
| 65 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 66 | } |
|
| 67 | ||
| 68 | private function get_where_sql( $config ) { |
|
| 69 | if ( is_array( $config ) ) { |
|
| @@ 180-192 (lines=13) @@ | ||
| 177 | return $this->estimate_full_sync_actions( $config ); |
|
| 178 | } |
|
| 179 | ||
| 180 | public function estimate_full_sync_actions( $config ) { |
|
| 181 | global $wpdb; |
|
| 182 | ||
| 183 | $query = "SELECT count(*) FROM $wpdb->usermeta"; |
|
| 184 | ||
| 185 | if ( $where_sql = $this->get_where_sql( $config ) ) { |
|
| 186 | $query .= ' WHERE ' . $where_sql; |
|
| 187 | } |
|
| 188 | ||
| 189 | $count = $wpdb->get_var( $query ); |
|
| 190 | ||
| 191 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 192 | } |
|
| 193 | ||
| 194 | private function get_where_sql( $config ) { |
|
| 195 | global $wpdb; |
|