| @@ 144-158 (lines=15) @@ | ||
| 141 | * @param array $config Full sync configuration for this sync module. |
|
| 142 | * @return int Number of items yet to be enqueued. |
|
| 143 | */ |
|
| 144 | public function estimate_full_sync_actions( $config ) { |
|
| 145 | global $wpdb; |
|
| 146 | ||
| 147 | $query = "SELECT count(*) FROM $wpdb->term_taxonomy"; |
|
| 148 | ||
| 149 | $where_sql = $this->get_where_sql( $config ); |
|
| 150 | if ( $where_sql ) { |
|
| 151 | $query .= ' WHERE ' . $where_sql; |
|
| 152 | } |
|
| 153 | ||
| 154 | // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared |
|
| 155 | $count = $wpdb->get_var( $query ); |
|
| 156 | ||
| 157 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Retrieve the actions that will be sent for this module during a full sync. |
|
| @@ 619-633 (lines=15) @@ | ||
| 616 | * @param array $config Full sync configuration for this sync module. |
|
| 617 | * @return array Number of items yet to be enqueued. |
|
| 618 | */ |
|
| 619 | public function estimate_full_sync_actions( $config ) { |
|
| 620 | global $wpdb; |
|
| 621 | ||
| 622 | $query = "SELECT count(*) FROM $wpdb->usermeta"; |
|
| 623 | ||
| 624 | $where_sql = $this->get_where_sql( $config ); |
|
| 625 | if ( $where_sql ) { |
|
| 626 | $query .= ' WHERE ' . $where_sql; |
|
| 627 | } |
|
| 628 | ||
| 629 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 630 | $count = $wpdb->get_var( $query ); |
|
| 631 | ||
| 632 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 633 | } |
|
| 634 | ||
| 635 | /** |
|
| 636 | * Retrieve the WHERE SQL clause based on the module config. |
|
| @@ 206-221 (lines=16) @@ | ||
| 203 | * @param array $config Full sync configuration for this sync module. |
|
| 204 | * @return int Number of items yet to be enqueued. |
|
| 205 | */ |
|
| 206 | public function estimate_full_sync_actions( $config ) { |
|
| 207 | global $wpdb; |
|
| 208 | ||
| 209 | $query = "SELECT count(*) FROM $wpdb->comments"; |
|
| 210 | ||
| 211 | $where_sql = $this->get_where_sql( $config ); |
|
| 212 | if ( $where_sql ) { |
|
| 213 | $query .= ' WHERE ' . $where_sql; |
|
| 214 | } |
|
| 215 | ||
| 216 | // TODO: Call $wpdb->prepare on the following query. |
|
| 217 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 218 | $count = $wpdb->get_var( $query ); |
|
| 219 | ||
| 220 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 221 | } |
|
| 222 | ||
| 223 | /** |
|
| 224 | * Retrieve the WHERE SQL clause based on the module config. |
|