Code Duplication    Length = 15-16 lines in 3 locations

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

@@ 228-243 (lines=16) @@
225
	 * @param array $config Full sync configuration for this sync module.
226
	 * @return int Number of items yet to be enqueued.
227
	 */
228
	public function estimate_full_sync_actions( $config ) {
229
		global $wpdb;
230
231
		$query = "SELECT count(*) FROM $wpdb->comments";
232
233
		$where_sql = $this->get_where_sql( $config );
234
		if ( $where_sql ) {
235
			$query .= ' WHERE ' . $where_sql;
236
		}
237
238
		// TODO: Call $wpdb->prepare on the following query.
239
		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
240
		$count = $wpdb->get_var( $query );
241
242
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
243
	}
244
245
	/**
246
	 * Retrieve the WHERE SQL clause based on the module config.

packages/sync/src/modules/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/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.