Code Duplication    Length = 15-16 lines in 3 locations

packages/sync/src/modules/Users.php 1 location

@@ 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.

packages/sync/src/modules/Comments.php 1 location

@@ 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.

packages/sync/src/modules/Terms.php 1 location

@@ 159-173 (lines=15) @@
156
	 * @param array $config Full sync configuration for this sync module.
157
	 * @return int Number of items yet to be enqueued.
158
	 */
159
	public function estimate_full_sync_actions( $config ) {
160
		global $wpdb;
161
162
		$query = "SELECT count(*) FROM $wpdb->term_taxonomy";
163
164
		$where_sql = $this->get_where_sql( $config );
165
		if ( $where_sql ) {
166
			$query .= ' WHERE ' . $where_sql;
167
		}
168
169
		// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
170
		$count = $wpdb->get_var( $query );
171
172
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
173
	}
174
175
	/**
176
	 * Retrieve the actions that will be sent for this module during a full sync.