Code Duplication    Length = 13-13 lines in 3 locations

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

@@ 109-121 (lines=13) @@
106
		return $this->enqueue_all_ids_as_action( 'jetpack_full_sync_comments', $wpdb->comments, 'comment_ID', $this->get_where_sql( $config ), $max_items_to_enqueue, $state );
107
	}
108
109
	public function estimate_full_sync_actions( $config ) {
110
		global $wpdb;
111
112
		$query = "SELECT count(*) FROM $wpdb->comments";
113
114
		if ( $where_sql = $this->get_where_sql( $config ) ) {
115
			$query .= ' WHERE ' . $where_sql;
116
		}
117
118
		$count = $wpdb->get_var( $query );
119
120
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
121
	}
122
123
	private function get_where_sql( $config ) {
124
		if ( is_array( $config ) ) {

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

@@ 46-58 (lines=13) @@
43
		return '';
44
	}
45
46
	public function estimate_full_sync_actions( $config ) {
47
		global $wpdb;
48
49
		$query = "SELECT count(*) FROM $wpdb->term_taxonomy";
50
51
		if ( $where_sql = $this->get_where_sql( $config ) ) {
52
			$query .= ' WHERE ' . $where_sql;
53
		}
54
55
		$count = $wpdb->get_var( $query );
56
57
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
58
	}
59
60
	function get_full_sync_actions() {
61
		return array( 'jetpack_full_sync_terms' );

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

@@ 393-405 (lines=13) @@
390
		return $this->enqueue_all_ids_as_action( 'jetpack_full_sync_users', $wpdb->usermeta, 'user_id', $this->get_where_sql( $config ), $max_items_to_enqueue, $state );
391
	}
392
393
	public function estimate_full_sync_actions( $config ) {
394
		global $wpdb;
395
396
		$query = "SELECT count(*) FROM $wpdb->usermeta";
397
398
		if ( $where_sql = $this->get_where_sql( $config ) ) {
399
			$query .= ' WHERE ' . $where_sql;
400
		}
401
402
		$count = $wpdb->get_var( $query );
403
404
		return (int) ceil( $count / self::ARRAY_CHUNK_SIZE );
405
	}
406
407
	private function get_where_sql( $config ) {
408
		global $wpdb;