Code Duplication    Length = 15-16 lines in 3 locations

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

@@ 320-335 (lines=16) @@
317
	 * @param array $config Full sync configuration for this sync module.
318
	 * @return int Number of items yet to be enqueued.
319
	 */
320
	public function estimate_full_sync_actions( $config ) {
321
		global $wpdb;
322
323
		$query = "SELECT count(*) FROM $wpdb->comments";
324
325
		$where_sql = $this->get_where_sql( $config );
326
		if ( $where_sql ) {
327
			$query .= ' WHERE ' . $where_sql;
328
		}
329
330
		// TODO: Call $wpdb->prepare on the following query.
331
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
332
		$count = $wpdb->get_var( $query );
333
334
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
335
	}
336
337
	/**
338
	 * Retrieve the WHERE SQL clause based on the module config.

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

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

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

@@ 642-656 (lines=15) @@
639
	 * @param array $config Full sync configuration for this sync module.
640
	 * @return array Number of items yet to be enqueued.
641
	 */
642
	public function estimate_full_sync_actions( $config ) {
643
		global $wpdb;
644
645
		$query = "SELECT count(*) FROM $wpdb->usermeta";
646
647
		$where_sql = $this->get_where_sql( $config );
648
		if ( $where_sql ) {
649
			$query .= ' WHERE ' . $where_sql;
650
		}
651
652
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
653
		$count = $wpdb->get_var( $query );
654
655
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
656
	}
657
658
	/**
659
	 * Retrieve the WHERE SQL clause based on the module config.