Code Duplication    Length = 15-16 lines in 3 locations

packages/sync/src/modules/class-comments.php 1 location

@@ 246-261 (lines=16) @@
243
	 * @param array $config Full sync configuration for this sync module.
244
	 * @return int Number of items yet to be enqueued.
245
	 */
246
	public function estimate_full_sync_actions( $config ) {
247
		global $wpdb;
248
249
		$query = "SELECT count(*) FROM $wpdb->comments";
250
251
		$where_sql = $this->get_where_sql( $config );
252
		if ( $where_sql ) {
253
			$query .= ' WHERE ' . $where_sql;
254
		}
255
256
		// TODO: Call $wpdb->prepare on the following query.
257
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
258
		$count = $wpdb->get_var( $query );
259
260
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
261
	}
262
263
	/**
264
	 * Retrieve the WHERE SQL clause based on the module config.

packages/sync/src/modules/class-terms.php 1 location

@@ 181-195 (lines=15) @@
178
	 * @param array $config Full sync configuration for this sync module.
179
	 * @return int Number of items yet to be enqueued.
180
	 */
181
	public function estimate_full_sync_actions( $config ) {
182
		global $wpdb;
183
184
		$query = "SELECT count(*) FROM $wpdb->term_taxonomy";
185
186
		$where_sql = $this->get_where_sql( $config );
187
		if ( $where_sql ) {
188
			$query .= ' WHERE ' . $where_sql;
189
		}
190
191
		// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
192
		$count = $wpdb->get_var( $query );
193
194
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
195
	}
196
197
	/**
198
	 * Retrieve the actions that will be sent for this module during a full sync.

packages/sync/src/modules/class-users.php 1 location

@@ 630-644 (lines=15) @@
627
	 * @param array $config Full sync configuration for this sync module.
628
	 * @return array Number of items yet to be enqueued.
629
	 */
630
	public function estimate_full_sync_actions( $config ) {
631
		global $wpdb;
632
633
		$query = "SELECT count(*) FROM $wpdb->usermeta";
634
635
		$where_sql = $this->get_where_sql( $config );
636
		if ( $where_sql ) {
637
			$query .= ' WHERE ' . $where_sql;
638
		}
639
640
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
641
		$count = $wpdb->get_var( $query );
642
643
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
644
	}
645
646
	/**
647
	 * Retrieve the WHERE SQL clause based on the module config.