| @@ 185-200 (lines=16) @@ | ||
| 182 | * @param array $config Full sync configuration for this sync module. |
|
| 183 | * @return int Number of items yet to be enqueued. |
|
| 184 | */ |
|
| 185 | public function estimate_full_sync_actions( $config ) { |
|
| 186 | global $wpdb; |
|
| 187 | ||
| 188 | $query = "SELECT count(*) FROM $wpdb->comments"; |
|
| 189 | ||
| 190 | $where_sql = $this->get_where_sql( $config ); |
|
| 191 | if ( $where_sql ) { |
|
| 192 | $query .= ' WHERE ' . $where_sql; |
|
| 193 | } |
|
| 194 | ||
| 195 | // TODO: Call $wpdb->prepare on the following query. |
|
| 196 | // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
|
| 197 | $count = $wpdb->get_var( $query ); |
|
| 198 | ||
| 199 | return (int) ceil( $count / self::ARRAY_CHUNK_SIZE ); |
|
| 200 | } |
|
| 201 | ||
| 202 | /** |
|
| 203 | * Retrieve the WHERE SQL clause based on the module config. |
|
| @@ 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. |
|