Code Duplication    Length = 21-21 lines in 2 locations

packages/sync/src/Replicastore.php 2 locations

@@ 44-64 (lines=21) @@
41
		// noop right now
42
	}
43
44
	public function post_count( $status = null, $min_id = null, $max_id = null ) {
45
		global $wpdb;
46
47
		$where = '';
48
49
		if ( $status ) {
50
			$where = "post_status = '" . esc_sql( $status ) . "'";
51
		} else {
52
			$where = '1=1';
53
		}
54
55
		if ( null != $min_id ) {
56
			$where .= ' AND ID >= ' . intval( $min_id );
57
		}
58
59
		if ( null != $max_id ) {
60
			$where .= ' AND ID <= ' . intval( $max_id );
61
		}
62
63
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE $where" );
64
	}
65
66
	// TODO: actually use max_id/min_id
67
	public function get_posts( $status = null, $min_id = null, $max_id = null ) {
@@ 160-180 (lines=21) @@
157
		return $this->table_checksum( $wpdb->postmeta, Defaults::$default_post_meta_checksum_columns, 'meta_id', \Jetpack_Sync_Settings::get_whitelisted_post_meta_sql(), $min_id, $max_id );
158
	}
159
160
	public function comment_count( $status = null, $min_id = null, $max_id = null ) {
161
		global $wpdb;
162
163
		$comment_approved = $this->comment_status_to_approval_value( $status );
164
165
		if ( $comment_approved !== false ) {
166
			$where = "comment_approved = '" . esc_sql( $comment_approved ) . "'";
167
		} else {
168
			$where = '1=1';
169
		}
170
171
		if ( $min_id != null ) {
172
			$where .= ' AND comment_ID >= ' . intval( $min_id );
173
		}
174
175
		if ( $max_id != null ) {
176
			$where .= ' AND comment_ID <= ' . intval( $max_id );
177
		}
178
179
		return $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE $where" );
180
	}
181
182
	private function comment_status_to_approval_value( $status ) {
183
		switch ( $status ) {